[Bug]/[Question]: Cache writer exception when dumping. Safe to ignore?
As4shi opened this issue · comments
Checklist
- The issue exists after disabling all extensions
- The issue exists on a clean installation of webui
- The issue is caused by an extension, but I believe it is caused by a bug in the webui
- The issue exists in the current version of the webui
- The issue has not been reported before recently
- The issue has been reported before but has not been fixed yet
What happened?
I'm having problems with a specific Lora causing an error with the json.dump function due to encoding.
It raises an exception when running json.dump(cache_data, file, indent=4, ensure_ascii=False)
in line 35 inside modules/cache.py
:
Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\threading.py", line 1016, in _bootstrap_inner
self.run()
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\threading.py", line 953, in run
self._target(*self._args, **self._kwargs)
File "D:\Stable Diffusion\stable-diffusion-webui-forge\modules\cache.py", line 35, in thread_func
json.dump(cache_data, file, indent=4, ensure_ascii=False)
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\json\__init__.py", line 180, in dump
fp.write(chunk)
UnicodeEncodeError: 'utf-8' codec can't encode characters in position 3-4: surrogates not allowed
I think I have identified the culprit, some keys inside ss_dataset_dirs
from this Lora: https://civitai.com/models/374922
Here is some data from the Lora (extracted using https://xypher7.github.io/lora-metadata-viewer/):
"1_\udcd1\udce6": {
"n_repeats": 1,
"img_count": 500
},
"1_Բ\udcc9\udcf1": {
"n_repeats": 1,
"img_count": 728
},
"1_\udcb6\udcf1ħ\udcd1\udce6": {
"n_repeats": 1,
"img_count": 514
}
For now I just removed it and the error seems to be gone. But either way, would that even gonna cause any problems besides rebuilding the cache each launch?... If it doesn't I might as well just keep it, otherwise I could look into implementing a fix.
Steps to reproduce the problem
- Download this Lora: https://civitai.com/models/374922
- Add it to your Lora folder
- Run webui
- Check the console
What should have happened?
Cache file should have been written until the end. It freezes after reading that part of the Lora metadata.
What browsers do you use to access the UI ?
Google Chrome
Sysinfo
Console logs
Already added relevant logs above.
Additional information
No response