diff options
author | butaixianran <butaixianran@qq.com> | 2023-03-24 18:05:00 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-24 18:05:00 +0000 |
commit | 803d44c4740f3de6b35fb7b9e3981a5eaf18b070 (patch) | |
tree | fb25424921607fa4d9460ffddc16f2f1956cf639 /javascript/extraNetworks.js | |
parent | a9fed7c364061ae6efb37f797b6b522cb3cf7aa2 (diff) | |
download | stable-diffusion-webui-gfx803-803d44c4740f3de6b35fb7b9e3981a5eaf18b070.tar.gz stable-diffusion-webui-gfx803-803d44c4740f3de6b35fb7b9e3981a5eaf18b070.tar.bz2 stable-diffusion-webui-gfx803-803d44c4740f3de6b35fb7b9e3981a5eaf18b070.zip |
Fix None type error for TI module
When user using model_name.png as a preview image, textural_inversion.py still treat it as an embeding, and didn't handle its error, just let python throw out an None type error like following:
```bash
File "D:\Work\Dev\AI\stable-diffusion-webui\modules\textual_inversion\textual_inversion.py", line 155, in load_from_file
name = data.get('name', name)
AttributeError: 'NoneType' object has no attribute 'get'
```
With just a simple `if data:` checking as following, there will be no error, breaks nothing, and now this module can works fine with user's preview images.
Old code:
```python
data = extract_image_data_embed(embed_image)
name = data.get('name', name)
```
New code:
```python
data = extract_image_data_embed(embed_image)
if data:
name = data.get('name', name)
else:
# if data is None, means this is not an embeding, just a preview image
return
```
Also, since there is no more errors on textual inversion module, from now on, extra network can set "model_name.png" as preview image for embedings.
Diffstat (limited to 'javascript/extraNetworks.js')
0 files changed, 0 insertions, 0 deletions