Spaces:
Sleeping
Sleeping
:tada: add negative embedding
Browse files
app.py
CHANGED
@@ -94,29 +94,27 @@ def inference(
|
|
94 |
|
95 |
progress(0.1, 'Loading pipeline...')
|
96 |
if model_id != current_model_id:
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
model_id = EXTERNAL_MODEL_MAPPING[model_id]
|
101 |
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
|
108 |
-
|
109 |
-
except Exception as e:
|
110 |
-
raise gr.Error(str(e))
|
111 |
|
112 |
if not safety_checker:
|
113 |
pipe.safety_checker = None
|
114 |
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
|
|
120 |
|
121 |
# Generation
|
122 |
progress(0.4, 'Generating images...')
|
|
|
94 |
|
95 |
progress(0.1, 'Loading pipeline...')
|
96 |
if model_id != current_model_id:
|
97 |
+
# For NOT Diffusers' Models
|
98 |
+
if model_id not in DIFFUSERS_MODEL_IDS:
|
99 |
+
model_id = EXTERNAL_MODEL_MAPPING[model_id]
|
|
|
100 |
|
101 |
+
pipe = DiffusionPipeline.from_pretrained(
|
102 |
+
model_id,
|
103 |
+
torch_dtype=dtype,
|
104 |
+
)
|
105 |
+
pipe.enable_sequential_cpu_offload()
|
106 |
|
107 |
+
current_model_id = model_id
|
|
|
|
|
108 |
|
109 |
if not safety_checker:
|
110 |
pipe.safety_checker = None
|
111 |
|
112 |
+
if model_id not in DIFFUSERS_MODEL_IDS:
|
113 |
+
progress(0.3, 'Loading Textual Inversion...')
|
114 |
+
# Load Textual Inversion
|
115 |
+
pipe.load_textual_inversion(
|
116 |
+
"checkpoints/embeddings/BadNegAnatomyV1 neg.pt", token='BadNegAnatomyV1-neg'
|
117 |
+
)
|
118 |
|
119 |
# Generation
|
120 |
progress(0.4, 'Generating images...')
|