stable-diffusion-webui/modules/textual_inversion
butaixianran 803d44c474
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.
2023-03-25 02:05:00 +08:00
..
autocrop.py Fix divide by 0 error 2022-12-02 12:16:29 -06:00
dataset.py fix for #6700 2023-02-19 12:44:56 +03:00
image_embedding.py print bucket sizes for training without resizing images #6620 2023-01-13 14:32:15 +03:00
learn_schedule.py Merge master 2022-10-30 18:57:51 +07:00
logging.py add fields to settings file 2023-01-15 12:41:00 -05:00
preprocess.py add data-dir flag and set all user data directories based on it 2023-01-27 14:44:30 +01:00
test_embedding.png Add files via upload 2022-10-11 20:20:46 +01:00
textual_inversion.py Fix None type error for TI module 2023-03-25 02:05:00 +08:00
ui.py Add interrupt button to preprocessing 2022-11-17 18:05:29 -08:00