AUTOMATIC1111 / stable-diffusion-webui

Stable Diffusion web UI
GNU Affero General Public License v3.0
139.17k stars 26.41k forks source link

Error loading embedding file #2382

Open sgpt55 opened 1 year ago

sgpt55 commented 1 year ago

Hi there, as long as I put an embedding file under /embeddings, the program will throw the info as follows:

Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug 1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)] Commit hash: cc5803603b8591075542d99ae8596ab5b130a82f Installing requirements for Web UI Launching Web UI with arguments: LatentDiffusion: Running in eps-prediction mode DiffusionWrapper has 859.52 M params. making attention of type 'vanilla' with 512 in_channels Working with z of shape (1, 4, 32, 32) = 4096 dimensions. making attention of type 'vanilla' with 512 in_channels Loading weights [45dee52b] from C:\Users\sgpt5\stable-diffusion-webui\models\Stable-diffusion\model.ckpt Global Step: 487750 Applying cross attention optimization (Doggettx). Model loaded. **Error verifying pickled file from C:\Users\sgpt5\stable-diffusion-webui\embeddings\mignon-62500.pt: Traceback (most recent call last): File "C:\Users\sgpt5\stable-diffusion-webui\modules\safe.py", line 76, in check_pt with zipfile.ZipFile(filename) as z: File "C:\Users\sgpt5\AppData\Local\Programs\Python\Python310\lib\zipfile.py", line 1267, in init self._RealGetContents() File "C:\Users\sgpt5\AppData\Local\Programs\Python\Python310\lib\zipfile.py", line 1334, in _RealGetContents raise BadZipFile("File is not a zip file") zipfile.BadZipFile: File is not a zip file

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\sgpt5\stable-diffusion-webui\modules\safe.py", line 97, in load check_pt(filename) File "C:\Users\sgpt5\stable-diffusion-webui\modules\safe.py", line 89, in check_pt unpickler.load() _pickle.UnpicklingError: invalid load key, '\x0a'.

The file may be malicious, so the program is not going to read it. You can skip this check with --disable-safe-unpickle commandline argument. Error loading emedding mignon-62500.pt: Traceback (most recent call last): File "C:\Users\sgpt5\stable-diffusion-webui\modules\textual_inversion\textual_inversion.py", line 132, in load_textual_inversion_embeddings process_file(fullfn, fn) File "C:\Users\sgpt5\stable-diffusion-webui\modules\textual_inversion\textual_inversion.py", line 102, in process_file if 'string_to_param' in data: TypeError: argument of type 'NoneType' is not iterable

Loaded a total of 0 textual inversion embeddings.** Running on local URL: http://127.0.0.1:7860

To create a public link, set share=True in launch().

I've been up-to-date and tried different embedding files, using Waifu Diffusion 1.2 weights and corresponding embedding file.

TheRealBlackNet commented 1 year ago

File "...\stable-diffusion-webui\modules\esrgan_model.py", line 24, in fix_model_layers raise Exception("The file is not a ESRGAN model.") Exception: The file is not a ESRGAN model.

have some other error but looks something big broke today.

realsama commented 1 year ago

I have had this issue also for two days now.

Sutranaut commented 1 year ago

I'm seeing the exact same error. I tested by removing all my embeds and relaunching, no errors. Replacing my embeds and errors return.

All my embeds came from hugging face or my training on google colab

nazodane commented 1 year ago

I found the problem.

>>> import zipfile
>>>  [i for i in zipfile.ZipFile('./embeddings/sks.pt').namelist() if i.endswith("/data.pkl")]
['sks/data.pkl']

here is my quick hack:

diff --git a/modules/safe.py b/modules/safe.py
index 399165a..dd57f75 100644
--- a/modules/safe.py
+++ b/modules/safe.py
@@ -74,9 +74,10 @@ def check_pt(filename):

         # new pytorch format is a zip file
         with zipfile.ZipFile(filename) as z:
-            check_zip_filenames(filename, z.namelist())
+#            check_zip_filenames(filename, z.namelist())

-            with z.open('archive/data.pkl') as file:
+            dpath =  [i for i in z.namelist() if i.endswith("/data.pkl")][0]
+            with z.open(dpath) as file:
                 unpickler = RestrictedUnpickler(file)
                 unpickler.load()
HannesGitH commented 1 year ago

@nazodane could you pls elaborate whats going on? i applied your patch and the error is no longer showing but i still cant see any embeddings in the train tab

HannesGitH commented 1 year ago

https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/3968#issuecomment-1308485736 has a better fix

etherealxx commented 1 year ago

i checked on colab, with current commit, --disable-safe-unpickle still has the same issue

axemaster commented 1 year ago

I'm seeing this today while trying to use the Train tab. I create the embedding and then it won't load. Same error.

etherealxx commented 1 year ago

i think this problem usually happen when you downloaded an embed from wrong/outdated links

skczhans commented 1 year ago

Even adding --disable-safe-unpickle still didn't solve the issue.I can still see the error code in cmd. `*** Error loading embedding rabbit.pt Traceback (most recent call last): File "G:\stable-diffusion-webui-master\modules\textual_inversion\textual_inversion.py", line 219, in load_from_dir self.load_from_file(fullfn, fn) File "G:\stable-diffusion-webui-master\modules\textual_inversion\textual_inversion.py", line 178, in load_from_file if 'string_to_param' in data: ^^^^^^^^^^^^^^^^^^^^^^^^^ File "G:\stable-diffusion-webui-master\venv\Lib\site-packages\torch_tensor.py", line 999, in contains raise RuntimeError( RuntimeError: Tensor.contains only supports Tensor or scalar, but you passed in a <class 'str'>.


*** Error loading embedding rabbit_optimized.pt Traceback (most recent call last): File "G:\stable-diffusion-webui-master\modules\textual_inversion\textual_inversion.py", line 219, in load_from_dir self.load_from_file(fullfn, fn) File "G:\stable-diffusion-webui-master\modules\textual_inversion\textual_inversion.py", line 178, in load_from_file if 'string_to_param' in data: ^^^^^^^^^^^^^^^^^^^^^^^^^ File "G:\stable-diffusion-webui-master\venv\Lib\site-packages\torch_tensor.py", line 999, in contains raise RuntimeError( RuntimeError: Tensor.contains only supports Tensor or scalar, but you passed in a <class 'str'>.

---`