Add use_safetensors=True to from_pretrained func

main
Uminosachi 2024-08-04 13:40:37 +09:00
parent ec5d27cb74
commit 71bdef2ba7
2 changed files with 19 additions and 12 deletions

View File

@ -66,16 +66,20 @@ To install the software, please follow these steps:
#### Model Cache
* The inpainting model, which is saved in HuggingFace's cache and includes `inpaint` (case-insensitive) in its repo_id, will also be added to the Inpainting Model ID dropdown list.
* If there's a specific model you'd like to use, you can cache it in advance using the following Python commands (venv/bin/python for Linux and MacOS):
```bash
venv\Scripts\python.exe
```
```python
from diffusers import StableDiffusionInpaintPipeline
pipe = StableDiffusionInpaintPipeline.from_pretrained("Uminosachi/dreamshaper_5-inpainting")
exit()
```
* If there's a specific model you'd like to use, you can cache it in advance using the following Python commands (`venv/bin/python` for Linux and MacOS):
```bash
venv\Scripts\python.exe
```
```python
from diffusers import StableDiffusionInpaintPipeline
pipe = StableDiffusionInpaintPipeline.from_pretrained("Uminosachi/dreamshaper_5-inpainting")
exit()
```
* The model diffusers downloaded is typically stored in your home directory. You can find it at `/home/username/.cache/huggingface/hub` for Linux and MacOS users, or at `C:\Users\username\.cache\huggingface\hub` for Windows users.
* When executing inpainting, if the following error is output to the console, try deleting the corresponding model from the cache folder mentioned above:
```
An error occurred while trying to fetch model name...
```
### Cleaner Tab

View File

@ -385,16 +385,19 @@ def run_inpaint(input_image, sel_mask, prompt, n_prompt, ddim_steps, cfg_scale,
torch_dtype = torch.float16
try:
pipe = StableDiffusionInpaintPipeline.from_pretrained(inp_model_id, torch_dtype=torch_dtype, local_files_only=local_files_only)
pipe = StableDiffusionInpaintPipeline.from_pretrained(
inp_model_id, torch_dtype=torch_dtype, local_files_only=local_files_only, use_safetensors=True)
except Exception as e:
ia_logging.error(str(e))
if not config_offline_inpainting:
try:
pipe = StableDiffusionInpaintPipeline.from_pretrained(inp_model_id, torch_dtype=torch_dtype)
pipe = StableDiffusionInpaintPipeline.from_pretrained(
inp_model_id, torch_dtype=torch_dtype, use_safetensors=True)
except Exception as e:
ia_logging.error(str(e))
try:
pipe = StableDiffusionInpaintPipeline.from_pretrained(inp_model_id, torch_dtype=torch_dtype, force_download=True)
pipe = StableDiffusionInpaintPipeline.from_pretrained(
inp_model_id, torch_dtype=torch_dtype, force_download=True, use_safetensors=True)
except Exception as e:
ia_logging.error(str(e))
return