Spaces:
Running
on
Zero
Running
on
Zero
adamelliotfields
commited on
Commit
•
4719a50
1
Parent(s):
4d5d84d
Update models
Browse files- DOCS.md +16 -26
- README.md +12 -12
- app.py +6 -3
- lib/config.py +8 -9
- lib/loader.py +2 -33
DOCS.md
CHANGED
@@ -10,9 +10,9 @@ Use `+` or `-` to increase the weight of a token. The weight grows exponentially
|
|
10 |
|
11 |
Groups of tokens can be weighted together by wrapping in parantheses and multiplying by a float between 0 and 2. For example, `(masterpiece, best quality)1.2` will increase the weight of both `masterpiece` and `best quality` by 1.2x.
|
12 |
|
13 |
-
This is the same syntax used in [InvokeAI](https://invoke-ai.github.io/InvokeAI/features/PROMPTS/) and it differs from AUTOMATIC1111:
|
14 |
|
15 |
-
| Compel |
|
16 |
| ----------- | ------------- |
|
17 |
| `blue++` | `((blue))` |
|
18 |
| `blue--` | `[[blue]]` |
|
@@ -21,32 +21,22 @@ This is the same syntax used in [InvokeAI](https://invoke-ai.github.io/InvokeAI/
|
|
21 |
|
22 |
### Models
|
23 |
|
24 |
-
|
25 |
|
26 |
-
* [
|
27 |
-
* [cyberdelia/CyberRealistic_V5](https://huggingface.co/cyberdelia/CyberRealistic)
|
28 |
-
* [
|
29 |
-
* [fluently/Fluently-v4](https://huggingface.co/fluently/Fluently-v4)
|
30 |
-
* [
|
31 |
-
* [
|
32 |
-
* [
|
33 |
-
* [XpucT/Deliberate_v6](https://huggingface.co/XpucT/Deliberate)
|
34 |
|
35 |
### Styles
|
36 |
|
37 |
-
[Styles](https://huggingface.co/spaces/adamelliotfields/diffusion/blob/main/data/styles.json) are prompt templates that wrap your positive and negative prompts.
|
38 |
|
39 |
-
|
40 |
-
|
41 |
-
#### Anime
|
42 |
-
|
43 |
-
The `Anime: *` styles work the best with Dreamshaper. When using the anime-specific Anything model, you should use the `Anime: Anything` style with the following settings:
|
44 |
-
|
45 |
-
* Scheduler: `DEIS 2M` or `DPM++ 2M`
|
46 |
-
* Guidance: `10`
|
47 |
-
* Steps: `50`
|
48 |
-
|
49 |
-
You subject should be a few simple tokens like `girl, brunette, blue eyes, armor, nebula, celestial`. Experiment with `Clip Skip` and `Karras`.
|
50 |
|
51 |
### Scale
|
52 |
|
@@ -54,7 +44,7 @@ Rescale up to 4x using [Real-ESRGAN](https://github.com/xinntao/Real-ESRGAN) wit
|
|
54 |
|
55 |
### Image-to-Image
|
56 |
|
57 |
-
The `Image-to-Image` settings allows you to provide input images for the initial
|
58 |
|
59 |
#### Strength
|
60 |
|
@@ -70,7 +60,7 @@ Currently, the only annotator available is [Canny](https://huggingface.co/lllyas
|
|
70 |
|
71 |
#### IP-Adapter
|
72 |
|
73 |
-
In an image-to-image pipeline, the input image is used as the initial latent. With [IP-Adapter](https://github.com/tencent-ailab/IP-Adapter), the
|
74 |
|
75 |
For capturing faces, enable `IP-Adapter Face` to use the full-face model. You should use an input image that is mostly a face and it should be high quality. You can generate fake portraits with Realistic Vision to experiment.
|
76 |
|
@@ -82,7 +72,7 @@ Enable `Use negative TI` to append [`fast_negative`](https://civitai.com/models/
|
|
82 |
|
83 |
#### DeepCache
|
84 |
|
85 |
-
[DeepCache](https://github.com/horseee/DeepCache) caches lower UNet layers and reuses them every
|
86 |
* `1`: no caching (default)
|
87 |
* `2`: more quality
|
88 |
* `3`: balanced
|
|
|
10 |
|
11 |
Groups of tokens can be weighted together by wrapping in parantheses and multiplying by a float between 0 and 2. For example, `(masterpiece, best quality)1.2` will increase the weight of both `masterpiece` and `best quality` by 1.2x.
|
12 |
|
13 |
+
This is the same syntax used in [InvokeAI](https://invoke-ai.github.io/InvokeAI/features/PROMPTS/) and it differs from [A1111](https://github.com/AUTOMATIC1111/stable-diffusion-webui):
|
14 |
|
15 |
+
| Compel | A1111 |
|
16 |
| ----------- | ------------- |
|
17 |
| `blue++` | `((blue))` |
|
18 |
| `blue--` | `[[blue]]` |
|
|
|
21 |
|
22 |
### Models
|
23 |
|
24 |
+
Some require specific parameters to get the best results, so check the model's link for more information:
|
25 |
|
26 |
+
* [Lykon/dreamshaper-8](https://huggingface.co/Lykon/dreamshaper-8)(default)
|
27 |
+
* [cyberdelia/CyberRealistic_V5](https://huggingface.co/cyberdelia/CyberRealistic)
|
28 |
+
* [dreamlike-art/dreamlike-photoreal-2.0](https://huggingface.co/dreamlike-art/dreamlike-photoreal-2.0)
|
29 |
+
* [fluently/Fluently-v4](https://huggingface.co/fluently/Fluently-v4)
|
30 |
+
* [s6yx/ReV_Animated](https://huggingface.co/s6yx/ReV_Animated)
|
31 |
+
* [SG161222/Realistic_Vision_V5](https://huggingface.co/SG161222/Realistic_Vision_V5.1_noVAE)
|
32 |
+
* [stable-diffusion-v1-5/stable-diffusion-v1-5](https://huggingface.co/stable-diffusion-v1-5/stable-diffusion-v1-5)
|
33 |
+
* [XpucT/Deliberate_v6](https://huggingface.co/XpucT/Deliberate)
|
34 |
|
35 |
### Styles
|
36 |
|
37 |
+
[Styles](https://huggingface.co/spaces/adamelliotfields/diffusion/blob/main/data/styles.json) are prompt templates that wrap your positive and negative prompts. Inspired by [twri/sdxl_prompt_styler](https://github.com/twri/sdxl_prompt_styler).
|
38 |
|
39 |
+
> 💡 When using syles, start with a simple prompt like `portrait of a cat` or `landscape of a mountain range`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
|
41 |
### Scale
|
42 |
|
|
|
44 |
|
45 |
### Image-to-Image
|
46 |
|
47 |
+
The `Image-to-Image` settings allows you to provide input images for the initial latent, ControlNet, and IP-Adapter.
|
48 |
|
49 |
#### Strength
|
50 |
|
|
|
60 |
|
61 |
#### IP-Adapter
|
62 |
|
63 |
+
In an image-to-image pipeline, the input image is used as the initial latent representation. With [IP-Adapter](https://github.com/tencent-ailab/IP-Adapter), the image is processed by a separate image encoder and the encoded features are used as conditioning along with the text prompt.
|
64 |
|
65 |
For capturing faces, enable `IP-Adapter Face` to use the full-face model. You should use an input image that is mostly a face and it should be high quality. You can generate fake portraits with Realistic Vision to experiment.
|
66 |
|
|
|
72 |
|
73 |
#### DeepCache
|
74 |
|
75 |
+
[DeepCache](https://github.com/horseee/DeepCache) caches lower UNet layers and reuses them every _n_ steps. Trade quality for speed:
|
76 |
* `1`: no caching (default)
|
77 |
* `2`: more quality
|
78 |
* `3`: balanced
|
README.md
CHANGED
@@ -15,31 +15,28 @@ header: mini
|
|
15 |
license: apache-2.0
|
16 |
models:
|
17 |
- ai-forever/Real-ESRGAN
|
18 |
-
- Comfy-Org/stable-diffusion-v1-5-archive
|
19 |
- cyberdelia/CyberRealistic
|
|
|
20 |
- fluently/Fluently-v4
|
21 |
- h94/IP-Adapter
|
22 |
-
- Linaqruf/anything-v3-1
|
23 |
- Lykon/dreamshaper-8
|
24 |
-
-
|
25 |
- SG161222/Realistic_Vision_V5.1_noVAE
|
|
|
26 |
- XpucT/Deliberate
|
27 |
preload_from_hub: # up to 10
|
28 |
-
- >-
|
29 |
-
Comfy-Org/stable-diffusion-v1-5-archive
|
30 |
-
v1-5-pruned-emaonly-fp16.safetensors
|
31 |
- >-
|
32 |
cyberdelia/CyberRealistic
|
33 |
CyberRealistic_V5_FP16.safetensors
|
|
|
|
|
|
|
34 |
- >-
|
35 |
fluently/Fluently-v4
|
36 |
Fluently-v4.safetensors
|
37 |
- >-
|
38 |
h94/IP-Adapter
|
39 |
models/ip-adapter-full-face_sd15.safetensors,models/ip-adapter-plus_sd15.safetensors,models/image_encoder/model.safetensors
|
40 |
-
- >-
|
41 |
-
Linaqruf/anything-v3-1
|
42 |
-
anything-v3-2.safetensors
|
43 |
- >-
|
44 |
lllyasviel/control_v11p_sd15_canny
|
45 |
diffusion_pytorch_model.fp16.safetensors
|
@@ -47,11 +44,14 @@ preload_from_hub: # up to 10
|
|
47 |
Lykon/dreamshaper-8
|
48 |
feature_extractor/preprocessor_config.json,safety_checker/config.json,scheduler/scheduler_config.json,text_encoder/config.json,text_encoder/model.fp16.safetensors,tokenizer/merges.txt,tokenizer/special_tokens_map.json,tokenizer/tokenizer_config.json,tokenizer/vocab.json,unet/config.json,unet/diffusion_pytorch_model.fp16.safetensors,vae/config.json,vae/diffusion_pytorch_model.fp16.safetensors,model_index.json
|
49 |
- >-
|
50 |
-
|
51 |
-
|
52 |
- >-
|
53 |
SG161222/Realistic_Vision_V5.1_noVAE
|
54 |
Realistic_Vision_V5.1_fp16-no-ema.safetensors
|
|
|
|
|
|
|
55 |
- >-
|
56 |
XpucT/Deliberate
|
57 |
Deliberate_v6.safetensors
|
@@ -83,7 +83,7 @@ git remote set-url origin https://adamelliotfields:$HF_TOKEN@huggingface.co/spac
|
|
83 |
# install
|
84 |
python -m venv .venv
|
85 |
source .venv/bin/activate
|
86 |
-
pip install -r requirements.txt
|
87 |
|
88 |
# gradio
|
89 |
python app.py --port 7860
|
|
|
15 |
license: apache-2.0
|
16 |
models:
|
17 |
- ai-forever/Real-ESRGAN
|
|
|
18 |
- cyberdelia/CyberRealistic
|
19 |
+
- dreamlike-art/dreamlike-photoreal-2.0
|
20 |
- fluently/Fluently-v4
|
21 |
- h94/IP-Adapter
|
|
|
22 |
- Lykon/dreamshaper-8
|
23 |
+
- s6yx/ReV_Animated
|
24 |
- SG161222/Realistic_Vision_V5.1_noVAE
|
25 |
+
- stable-diffusion-v1-5/stable-diffusion-v1-5
|
26 |
- XpucT/Deliberate
|
27 |
preload_from_hub: # up to 10
|
|
|
|
|
|
|
28 |
- >-
|
29 |
cyberdelia/CyberRealistic
|
30 |
CyberRealistic_V5_FP16.safetensors
|
31 |
+
- >-
|
32 |
+
dreamlike-art/dreamlike-photoreal-2.0
|
33 |
+
dreamlike-photoreal-2.0.safetensors
|
34 |
- >-
|
35 |
fluently/Fluently-v4
|
36 |
Fluently-v4.safetensors
|
37 |
- >-
|
38 |
h94/IP-Adapter
|
39 |
models/ip-adapter-full-face_sd15.safetensors,models/ip-adapter-plus_sd15.safetensors,models/image_encoder/model.safetensors
|
|
|
|
|
|
|
40 |
- >-
|
41 |
lllyasviel/control_v11p_sd15_canny
|
42 |
diffusion_pytorch_model.fp16.safetensors
|
|
|
44 |
Lykon/dreamshaper-8
|
45 |
feature_extractor/preprocessor_config.json,safety_checker/config.json,scheduler/scheduler_config.json,text_encoder/config.json,text_encoder/model.fp16.safetensors,tokenizer/merges.txt,tokenizer/special_tokens_map.json,tokenizer/tokenizer_config.json,tokenizer/vocab.json,unet/config.json,unet/diffusion_pytorch_model.fp16.safetensors,vae/config.json,vae/diffusion_pytorch_model.fp16.safetensors,model_index.json
|
46 |
- >-
|
47 |
+
s6yx/ReV_Animated
|
48 |
+
rev_1.2.2/rev_1.2.2-fp16.safetensors
|
49 |
- >-
|
50 |
SG161222/Realistic_Vision_V5.1_noVAE
|
51 |
Realistic_Vision_V5.1_fp16-no-ema.safetensors
|
52 |
+
- >-
|
53 |
+
stable-diffusion-v1-5/stable-diffusion-v1-5
|
54 |
+
feature_extractor/preprocessor_config.json,safety_checker/config.json,scheduler/scheduler_config.json,text_encoder/config.json,text_encoder/model.fp16.safetensors,tokenizer/merges.txt,tokenizer/special_tokens_map.json,tokenizer/tokenizer_config.json,tokenizer/vocab.json,unet/config.json,unet/diffusion_pytorch_model.fp16.safetensors,vae/config.json,vae/diffusion_pytorch_model.fp16.safetensors,model_index.json
|
55 |
- >-
|
56 |
XpucT/Deliberate
|
57 |
Deliberate_v6.safetensors
|
|
|
83 |
# install
|
84 |
python -m venv .venv
|
85 |
source .venv/bin/activate
|
86 |
+
pip install -r requirements.txt
|
87 |
|
88 |
# gradio
|
89 |
python app.py --port 7860
|
app.py
CHANGED
@@ -185,12 +185,14 @@ with gr.Blocks(
|
|
185 |
negative_prompt = gr.Textbox(
|
186 |
label="Negative Prompt",
|
187 |
value="nsfw+",
|
|
|
188 |
lines=1,
|
189 |
)
|
190 |
styles = json.loads(read_file("data/styles.json"))
|
191 |
style_ids = list(styles.keys())
|
192 |
style_ids = [sid for sid in style_ids if not sid.startswith("_")]
|
193 |
style = gr.Dropdown(
|
|
|
194 |
value=Config.STYLE,
|
195 |
label="Style Template",
|
196 |
choices=[("None", "none")] + [(styles[sid]["name"], sid) for sid in style_ids],
|
@@ -345,17 +347,17 @@ with gr.Blocks(
|
|
345 |
)
|
346 |
with gr.Row():
|
347 |
disable_image = gr.Checkbox(
|
348 |
-
label="Disable
|
349 |
elem_classes=["checkbox"],
|
350 |
value=False,
|
351 |
)
|
352 |
disable_control_image = gr.Checkbox(
|
353 |
-
label="Disable ControlNet
|
354 |
elem_classes=["checkbox"],
|
355 |
value=False,
|
356 |
)
|
357 |
disable_ip_image = gr.Checkbox(
|
358 |
-
label="Disable IP-Adapter
|
359 |
elem_classes=["checkbox"],
|
360 |
value=False,
|
361 |
)
|
@@ -413,6 +415,7 @@ with gr.Blocks(
|
|
413 |
fn=lambda image, control_image, ip_image: (image, control_image, ip_image),
|
414 |
inputs=[disable_image, disable_control_image, disable_ip_image],
|
415 |
outputs=[DISABLE_IMAGE_PROMPT, DISABLE_CONTROL_IMAGE_PROMPT, DISABLE_IP_IMAGE_PROMPT],
|
|
|
416 |
)
|
417 |
|
418 |
# Generate images
|
|
|
185 |
negative_prompt = gr.Textbox(
|
186 |
label="Negative Prompt",
|
187 |
value="nsfw+",
|
188 |
+
min_width=320,
|
189 |
lines=1,
|
190 |
)
|
191 |
styles = json.loads(read_file("data/styles.json"))
|
192 |
style_ids = list(styles.keys())
|
193 |
style_ids = [sid for sid in style_ids if not sid.startswith("_")]
|
194 |
style = gr.Dropdown(
|
195 |
+
min_width=320,
|
196 |
value=Config.STYLE,
|
197 |
label="Style Template",
|
198 |
choices=[("None", "none")] + [(styles[sid]["name"], sid) for sid in style_ids],
|
|
|
347 |
)
|
348 |
with gr.Row():
|
349 |
disable_image = gr.Checkbox(
|
350 |
+
label="Disable initial image",
|
351 |
elem_classes=["checkbox"],
|
352 |
value=False,
|
353 |
)
|
354 |
disable_control_image = gr.Checkbox(
|
355 |
+
label="Disable ControlNet",
|
356 |
elem_classes=["checkbox"],
|
357 |
value=False,
|
358 |
)
|
359 |
disable_ip_image = gr.Checkbox(
|
360 |
+
label="Disable IP-Adapter",
|
361 |
elem_classes=["checkbox"],
|
362 |
value=False,
|
363 |
)
|
|
|
415 |
fn=lambda image, control_image, ip_image: (image, control_image, ip_image),
|
416 |
inputs=[disable_image, disable_control_image, disable_ip_image],
|
417 |
outputs=[DISABLE_IMAGE_PROMPT, DISABLE_CONTROL_IMAGE_PROMPT, DISABLE_IP_IMAGE_PROMPT],
|
418 |
+
show_api=False,
|
419 |
)
|
420 |
|
421 |
# Generate images
|
lib/config.py
CHANGED
@@ -62,14 +62,14 @@ Config = SimpleNamespace(
|
|
62 |
HF_MODELS={
|
63 |
# downloaded on startup
|
64 |
"ai-forever/Real-ESRGAN": ["RealESRGAN_x2.pth", "RealESRGAN_x4.pth"],
|
65 |
-
"Comfy-Org/stable-diffusion-v1-5-archive": ["v1-5-pruned-emaonly-fp16.safetensors"],
|
66 |
"cyberdelia/CyberRealistic": ["CyberRealistic_V5_FP16.safetensors"],
|
|
|
67 |
"fluently/Fluently-v4": ["Fluently-v4.safetensors"],
|
68 |
-
"Linaqruf/anything-v3-1": ["anything-v3-2.safetensors"],
|
69 |
"lllyasviel/control_v11p_sd15_canny": ["diffusion_pytorch_model.fp16.safetensors"],
|
70 |
"Lykon/dreamshaper-8": [*sd_files],
|
71 |
-
"
|
72 |
"SG161222/Realistic_Vision_V5.1_noVAE": ["Realistic_Vision_V5.1_fp16-no-ema.safetensors"],
|
|
|
73 |
"XpucT/Deliberate": ["Deliberate_v6.safetensors"],
|
74 |
},
|
75 |
MONO_FONTS=["monospace"],
|
@@ -88,23 +88,22 @@ Config = SimpleNamespace(
|
|
88 |
},
|
89 |
MODEL="Lykon/dreamshaper-8",
|
90 |
MODELS=[
|
91 |
-
"Comfy-Org/stable-diffusion-v1-5-archive",
|
92 |
"cyberdelia/CyberRealistic",
|
|
|
93 |
"fluently/Fluently-v4",
|
94 |
-
"Linaqruf/anything-v3-1",
|
95 |
"Lykon/dreamshaper-8",
|
96 |
-
"
|
97 |
"SG161222/Realistic_Vision_V5.1_noVAE",
|
|
|
98 |
"XpucT/Deliberate",
|
99 |
],
|
100 |
# Single-file model weights
|
101 |
MODEL_CHECKPOINTS={
|
102 |
# keep keys lowercase for case-insensitive matching in the loader
|
103 |
-
"comfy-org/stable-diffusion-v1-5-archive": "v1-5-pruned-emaonly-fp16.safetensors",
|
104 |
"cyberdelia/cyberrealistic": "CyberRealistic_V5_FP16.safetensors",
|
|
|
105 |
"fluently/fluently-v4": "Fluently-v4.safetensors",
|
106 |
-
"
|
107 |
-
"prompthero/openjourney-v4": "openjourney-v4.ckpt",
|
108 |
"sg161222/realistic_vision_v5.1_novae": "Realistic_Vision_V5.1_fp16-no-ema.safetensors",
|
109 |
"xpuct/deliberate": "Deliberate_v6.safetensors",
|
110 |
},
|
|
|
62 |
HF_MODELS={
|
63 |
# downloaded on startup
|
64 |
"ai-forever/Real-ESRGAN": ["RealESRGAN_x2.pth", "RealESRGAN_x4.pth"],
|
|
|
65 |
"cyberdelia/CyberRealistic": ["CyberRealistic_V5_FP16.safetensors"],
|
66 |
+
"dreamlike-art/dreamlike-photoreal-2.0": ["dreamlike-photoreal-2.0.safetensors"],
|
67 |
"fluently/Fluently-v4": ["Fluently-v4.safetensors"],
|
|
|
68 |
"lllyasviel/control_v11p_sd15_canny": ["diffusion_pytorch_model.fp16.safetensors"],
|
69 |
"Lykon/dreamshaper-8": [*sd_files],
|
70 |
+
"s6yx/ReV_Animated": ["rev_1.2.2/rev_1.2.2-fp16.safetensors"],
|
71 |
"SG161222/Realistic_Vision_V5.1_noVAE": ["Realistic_Vision_V5.1_fp16-no-ema.safetensors"],
|
72 |
+
"stable-diffusion-v1-5/stable-diffusion-v1-5": [*sd_files],
|
73 |
"XpucT/Deliberate": ["Deliberate_v6.safetensors"],
|
74 |
},
|
75 |
MONO_FONTS=["monospace"],
|
|
|
88 |
},
|
89 |
MODEL="Lykon/dreamshaper-8",
|
90 |
MODELS=[
|
|
|
91 |
"cyberdelia/CyberRealistic",
|
92 |
+
"dreamlike-art/dreamlike-photoreal-2.0",
|
93 |
"fluently/Fluently-v4",
|
|
|
94 |
"Lykon/dreamshaper-8",
|
95 |
+
"s6yx/ReV_Animated",
|
96 |
"SG161222/Realistic_Vision_V5.1_noVAE",
|
97 |
+
"stable-diffusion-v1-5/stable-diffusion-v1-5",
|
98 |
"XpucT/Deliberate",
|
99 |
],
|
100 |
# Single-file model weights
|
101 |
MODEL_CHECKPOINTS={
|
102 |
# keep keys lowercase for case-insensitive matching in the loader
|
|
|
103 |
"cyberdelia/cyberrealistic": "CyberRealistic_V5_FP16.safetensors",
|
104 |
+
"dreamlike-art/dreamlike-photoreal-2.0": "dreamlike-photoreal-2.0.safetensors",
|
105 |
"fluently/fluently-v4": "Fluently-v4.safetensors",
|
106 |
+
"s6yx/rev_animated": "rev_1.2.2/rev_1.2.2-fp16.safetensors",
|
|
|
107 |
"sg161222/realistic_vision_v5.1_novae": "Realistic_Vision_V5.1_fp16-no-ema.safetensors",
|
108 |
"xpuct/deliberate": "Deliberate_v6.safetensors",
|
109 |
},
|
lib/loader.py
CHANGED
@@ -4,7 +4,6 @@ from threading import Lock
|
|
4 |
import torch
|
5 |
from DeepCache import DeepCacheSDHelper
|
6 |
from diffusers import ControlNetModel
|
7 |
-
from diffusers.models import AutoencoderKL
|
8 |
from diffusers.models.attention_processor import AttnProcessor2_0, IPAdapterAttnProcessor2_0
|
9 |
|
10 |
from .config import Config
|
@@ -238,23 +237,6 @@ class Loader:
|
|
238 |
if self.pipe is not None:
|
239 |
self.pipe.set_progress_bar_config(disable=progress is not None)
|
240 |
|
241 |
-
# Handle single-file and diffusers-style models
|
242 |
-
def _load_vae(self, model=""):
|
243 |
-
msg = "Loading VAE"
|
244 |
-
with timer(msg, logger=self.log.info):
|
245 |
-
if model.lower() in Config.MODEL_CHECKPOINTS.keys():
|
246 |
-
self.pipe.vae = AutoencoderKL.from_single_file(
|
247 |
-
f"https://huggingface.co/{model}/{Config.MODEL_CHECKPOINTS[model.lower()]}",
|
248 |
-
torch_dtype=self.pipe.dtype,
|
249 |
-
).to(self.pipe.device)
|
250 |
-
else:
|
251 |
-
self.pipe.vae = AutoencoderKL.from_pretrained(
|
252 |
-
pretrained_model_name_or_path=model,
|
253 |
-
torch_dtype=self.pipe.dtype,
|
254 |
-
subfolder="vae",
|
255 |
-
variant="fp16",
|
256 |
-
).to(self.pipe.device)
|
257 |
-
|
258 |
def load(
|
259 |
self,
|
260 |
kind,
|
@@ -267,8 +249,6 @@ class Loader:
|
|
267 |
karras,
|
268 |
progress,
|
269 |
):
|
270 |
-
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
271 |
-
|
272 |
scheduler_kwargs = {
|
273 |
"beta_schedule": "scaled_linear",
|
274 |
"timestep_spacing": "leading",
|
@@ -297,16 +277,8 @@ class Loader:
|
|
297 |
else:
|
298 |
pipe_kwargs["variant"] = None
|
299 |
|
300 |
-
#
|
301 |
-
|
302 |
-
pipe_kwargs["torch_dtype"] = (
|
303 |
-
torch.bfloat16
|
304 |
-
if torch.cuda.get_device_properties(device).major >= 8
|
305 |
-
else torch.float16
|
306 |
-
)
|
307 |
-
else:
|
308 |
-
# defaults to float32
|
309 |
-
pipe_kwargs["torch_dtype"] = torch.float16
|
310 |
|
311 |
# config maps the repo to the ID: canny -> lllyasviel/control_sd15_canny
|
312 |
if kind.startswith("controlnet_"):
|
@@ -339,9 +311,6 @@ class Loader:
|
|
339 |
if not same_scheduler or not same_karras:
|
340 |
self.pipe.scheduler = Config.SCHEDULERS[scheduler](**scheduler_kwargs)
|
341 |
|
342 |
-
# Load VAE
|
343 |
-
self._load_vae(model)
|
344 |
-
|
345 |
CURRENT_STEP = 1
|
346 |
TOTAL_STEPS = sum(
|
347 |
[
|
|
|
4 |
import torch
|
5 |
from DeepCache import DeepCacheSDHelper
|
6 |
from diffusers import ControlNetModel
|
|
|
7 |
from diffusers.models.attention_processor import AttnProcessor2_0, IPAdapterAttnProcessor2_0
|
8 |
|
9 |
from .config import Config
|
|
|
237 |
if self.pipe is not None:
|
238 |
self.pipe.set_progress_bar_config(disable=progress is not None)
|
239 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
240 |
def load(
|
241 |
self,
|
242 |
kind,
|
|
|
249 |
karras,
|
250 |
progress,
|
251 |
):
|
|
|
|
|
252 |
scheduler_kwargs = {
|
253 |
"beta_schedule": "scaled_linear",
|
254 |
"timestep_spacing": "leading",
|
|
|
277 |
else:
|
278 |
pipe_kwargs["variant"] = None
|
279 |
|
280 |
+
# converts to fp32 by default
|
281 |
+
pipe_kwargs["torch_dtype"] = torch.float16
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
282 |
|
283 |
# config maps the repo to the ID: canny -> lllyasviel/control_sd15_canny
|
284 |
if kind.startswith("controlnet_"):
|
|
|
311 |
if not same_scheduler or not same_karras:
|
312 |
self.pipe.scheduler = Config.SCHEDULERS[scheduler](**scheduler_kwargs)
|
313 |
|
|
|
|
|
|
|
314 |
CURRENT_STEP = 1
|
315 |
TOTAL_STEPS = sum(
|
316 |
[
|