Spaces:
Running
on
Zero
Running
on
Zero
Commit
•
f5f53dc
1
Parent(s):
9126c78
Update app.py
Browse files
app.py
CHANGED
@@ -27,6 +27,8 @@ from insightface.app import FaceAnalysis
|
|
27 |
from pipeline_stable_diffusion_xl_instantid_img2img import StableDiffusionXLInstantIDImg2ImgPipeline, draw_kps
|
28 |
from controlnet_aux import ZoeDetector
|
29 |
|
|
|
|
|
30 |
with open("sdxl_loras.json", "r") as file:
|
31 |
data = json.load(file)
|
32 |
sdxl_loras_raw = [
|
@@ -107,6 +109,9 @@ pipe = StableDiffusionXLInstantIDImg2ImgPipeline.from_pretrained("rubbrband/albe
|
|
107 |
vae=vae,
|
108 |
controlnet=[identitynet, zoedepthnet],
|
109 |
torch_dtype=torch.float16)
|
|
|
|
|
|
|
110 |
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config, use_karras_sigmas=True)
|
111 |
pipe.load_ip_adapter_instantid(face_adapter)
|
112 |
pipe.set_ip_adapter_scale(0.8)
|
@@ -268,10 +273,14 @@ def run_lora(face_image, prompt, negative, lora_scale, selected_state, face_stre
|
|
268 |
pipe.unload_textual_inversion()
|
269 |
pipe.load_textual_inversion(state_dict_embedding["text_encoders_0"], token=["<s0>", "<s1>"], text_encoder=pipe.text_encoder, tokenizer=pipe.tokenizer)
|
270 |
pipe.load_textual_inversion(state_dict_embedding["text_encoders_1"], token=["<s0>", "<s1>"], text_encoder=pipe.text_encoder_2, tokenizer=pipe.tokenizer_2)
|
271 |
-
|
|
|
|
|
272 |
image = pipe(
|
273 |
-
|
274 |
-
|
|
|
|
|
275 |
width=1024,
|
276 |
height=1024,
|
277 |
image_embeds=face_emb,
|
|
|
27 |
from pipeline_stable_diffusion_xl_instantid_img2img import StableDiffusionXLInstantIDImg2ImgPipeline, draw_kps
|
28 |
from controlnet_aux import ZoeDetector
|
29 |
|
30 |
+
from compel import Compel, ReturnedEmbeddingsType
|
31 |
+
|
32 |
with open("sdxl_loras.json", "r") as file:
|
33 |
data = json.load(file)
|
34 |
sdxl_loras_raw = [
|
|
|
109 |
vae=vae,
|
110 |
controlnet=[identitynet, zoedepthnet],
|
111 |
torch_dtype=torch.float16)
|
112 |
+
|
113 |
+
compel = Compel(tokenizer=[pipe.tokenizer, pipeline.tokenizer_2] , text_encoder=[pipe.text_encoder, pipe.text_encoder_2], returned_embeddings_type=ReturnedEmbeddingsType.PENULTIMATE_HIDDEN_STATES_NON_NORMALIZED, requires_pooled=[False, True])
|
114 |
+
|
115 |
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config, use_karras_sigmas=True)
|
116 |
pipe.load_ip_adapter_instantid(face_adapter)
|
117 |
pipe.set_ip_adapter_scale(0.8)
|
|
|
273 |
pipe.unload_textual_inversion()
|
274 |
pipe.load_textual_inversion(state_dict_embedding["text_encoders_0"], token=["<s0>", "<s1>"], text_encoder=pipe.text_encoder, tokenizer=pipe.tokenizer)
|
275 |
pipe.load_textual_inversion(state_dict_embedding["text_encoders_1"], token=["<s0>", "<s1>"], text_encoder=pipe.text_encoder_2, tokenizer=pipe.tokenizer_2)
|
276 |
+
|
277 |
+
conditioning, pooled = compel(prompt)
|
278 |
+
negative_conditioning, negative_pooled = compel(negative)
|
279 |
image = pipe(
|
280 |
+
prompt_embeds=conditioning,
|
281 |
+
pooled_prompt_embeds=pooled,
|
282 |
+
negative_prompt_embeds=negative_conditioning,
|
283 |
+
negative_pooled_prompt_embeds=negative_pooled,
|
284 |
width=1024,
|
285 |
height=1024,
|
286 |
image_embeds=face_emb,
|