前言
本文是AI繪畫子模型Lora的訓(xùn)練工具kohya_ss的報(bào)錯(cuò)解決。不含Stable Diffustion使用相關(guān)的信息。
工具鏈接:kohya_ss
癥狀
在Win11 23H2下運(yùn)行setup.bat,選1安裝后選6啟動(dòng),成功進(jìn)入webUI界面,填完參數(shù)以后點(diǎn)開始訓(xùn)練。報(bào)以下錯(cuò)誤:
OSError: Can't load tokenizer for 'openai/clip-vit-large-patch14'. If you were trying to load it from 'https://huggingface.co/models', make sure you don't have a local directory with the same name. Otherwise, make sure 'openai/clip-vit-large-patch14' is the correct path to a directory containing all relevant files for a CLIPTokenizer tokenizer.
初步判斷是因?yàn)檫B不上huggingface,無法下載模型導(dǎo)致的。sd本體也有不少人遇到這個(gè)問題,解決辦法是手動(dòng)下載之后改代碼里的指向路徑。
解決辦法
手動(dòng)下載
首先訪問 這個(gè)倉庫,切換到File And Versions選項(xiàng)卡,點(diǎn)文件大小右邊的 ↓依次下載所有文件,然后保存到同一個(gè)目錄。例如:D:\clip-vit-large-patch14,如果是Linux平臺(tái)記得檢查一下文件權(quán)限。
改變代碼指向
打開venv\Lib\site-packages\transformers\tokenization_utils_base.py這個(gè)文件,搜索
pretrained_model_name_or_path = str(pretrained_model_name_or_path)
改成
pretrained_model_name_or_path = "D:\models--openai--clip-vit-large-patch14" <-剛才手動(dòng)下載保存的路徑
最后重啟軟件就可以了,一定要重啟軟件!因?yàn)檫@個(gè)路徑是在軟件啟動(dòng)的時(shí)候加載的。