Spaces:
Runtime error
Runtime error
cocktailpeanut
commited on
Commit
•
3f5ca38
1
Parent(s):
a89c9f7
update
Browse files- app.py +25 -15
- requirements.txt +3 -2
app.py
CHANGED
@@ -33,7 +33,7 @@ from pipeline_stable_diffusion_xl_instantid_img2img import StableDiffusionXLInst
|
|
33 |
from controlnet_aux import ZoeDetector
|
34 |
|
35 |
from compel import Compel, ReturnedEmbeddingsType
|
36 |
-
import spaces
|
37 |
|
38 |
#from gradio_imageslider import ImageSlider
|
39 |
|
@@ -61,7 +61,17 @@ with open("defaults_data.json", "r") as file:
|
|
61 |
lora_defaults = json.load(file)
|
62 |
|
63 |
|
64 |
-
device = "cuda"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
|
66 |
state_dicts = {}
|
67 |
|
@@ -84,32 +94,32 @@ sdxl_loras_raw = [item for item in sdxl_loras_raw if item.get("new") != True]
|
|
84 |
hf_hub_download(
|
85 |
repo_id="InstantX/InstantID",
|
86 |
filename="ControlNetModel/config.json",
|
87 |
-
local_dir="
|
88 |
)
|
89 |
hf_hub_download(
|
90 |
repo_id="InstantX/InstantID",
|
91 |
filename="ControlNetModel/diffusion_pytorch_model.safetensors",
|
92 |
-
local_dir="
|
93 |
)
|
94 |
hf_hub_download(
|
95 |
-
repo_id="InstantX/InstantID", filename="ip-adapter.bin", local_dir="
|
96 |
)
|
97 |
hf_hub_download(
|
98 |
repo_id="latent-consistency/lcm-lora-sdxl",
|
99 |
filename="pytorch_lora_weights.safetensors",
|
100 |
-
local_dir="
|
101 |
)
|
102 |
-
|
103 |
-
if not os.path.exists("
|
104 |
-
gdown.download(url="https://drive.google.com/file/d/18wEUfMNohBJ4K3Ly5wpTejPfDzp-8fI8/view?usp=sharing", output="
|
105 |
-
os.system("unzip /data/antelopev2.zip -d /data/models/")
|
106 |
|
107 |
app = FaceAnalysis(name='antelopev2', root='/data', providers=['CPUExecutionProvider'])
|
108 |
app.prepare(ctx_id=0, det_size=(640, 640))
|
109 |
|
110 |
# prepare models under ./checkpoints
|
111 |
-
face_adapter = f'
|
112 |
-
controlnet_path = f'
|
113 |
|
114 |
# load IdentityNet
|
115 |
st = time.time()
|
@@ -226,7 +236,7 @@ def merge_incompatible_lora(full_path_lora, lora_scale):
|
|
226 |
)
|
227 |
del weights_sd
|
228 |
del lora_model
|
229 |
-
|
230 |
def generate_image(prompt, negative, face_emb, face_image, face_kps, image_strength, guidance_scale, face_strength, depth_control_scale, repo_name, loaded_state_dict, lora_scale, sdxl_loras, selected_state_index, st):
|
231 |
print(loaded_state_dict)
|
232 |
et = time.time()
|
@@ -487,7 +497,7 @@ def remove_custom_lora():
|
|
487 |
with gr.Blocks(css="custom.css") as demo:
|
488 |
gr_sdxl_loras = gr.State(value=sdxl_loras_raw)
|
489 |
title = gr.HTML(
|
490 |
-
"""<h1
|
491 |
<span>Face to All<br><small style="
|
492 |
font-size: 13px;
|
493 |
display: block;
|
@@ -597,4 +607,4 @@ with gr.Blocks(css="custom.css") as demo:
|
|
597 |
share_button.click(None, [], [], js=share_js)
|
598 |
demo.load(fn=classify_gallery, inputs=[gr_sdxl_loras], outputs=[gallery, gr_sdxl_loras], queue=False, js=js)
|
599 |
demo.queue(max_size=20)
|
600 |
-
demo.launch(share=True)
|
|
|
33 |
from controlnet_aux import ZoeDetector
|
34 |
|
35 |
from compel import Compel, ReturnedEmbeddingsType
|
36 |
+
#import spaces
|
37 |
|
38 |
#from gradio_imageslider import ImageSlider
|
39 |
|
|
|
61 |
lora_defaults = json.load(file)
|
62 |
|
63 |
|
64 |
+
#device = "cuda"
|
65 |
+
if torch.cuda.is_available():
|
66 |
+
device = "cuda"
|
67 |
+
dtype = torch.float16
|
68 |
+
elif torch.backends.mps.is_available():
|
69 |
+
device = "mps"
|
70 |
+
dtype = torch.float32
|
71 |
+
else:
|
72 |
+
device = "cpu"
|
73 |
+
dtype = torch.float32
|
74 |
+
|
75 |
|
76 |
state_dicts = {}
|
77 |
|
|
|
94 |
hf_hub_download(
|
95 |
repo_id="InstantX/InstantID",
|
96 |
filename="ControlNetModel/config.json",
|
97 |
+
local_dir="data/checkpoints",
|
98 |
)
|
99 |
hf_hub_download(
|
100 |
repo_id="InstantX/InstantID",
|
101 |
filename="ControlNetModel/diffusion_pytorch_model.safetensors",
|
102 |
+
local_dir="data/checkpoints",
|
103 |
)
|
104 |
hf_hub_download(
|
105 |
+
repo_id="InstantX/InstantID", filename="ip-adapter.bin", local_dir="data/checkpoints"
|
106 |
)
|
107 |
hf_hub_download(
|
108 |
repo_id="latent-consistency/lcm-lora-sdxl",
|
109 |
filename="pytorch_lora_weights.safetensors",
|
110 |
+
local_dir="data/checkpoints",
|
111 |
)
|
112 |
+
## download antelopev2
|
113 |
+
#if not os.path.exists("data/antelopev2.zip"):
|
114 |
+
# gdown.download(url="https://drive.google.com/file/d/18wEUfMNohBJ4K3Ly5wpTejPfDzp-8fI8/view?usp=sharing", output="data/", quiet=False, fuzzy=True)
|
115 |
+
# os.system("unzip /data/antelopev2.zip -d /data/models/")
|
116 |
|
117 |
app = FaceAnalysis(name='antelopev2', root='/data', providers=['CPUExecutionProvider'])
|
118 |
app.prepare(ctx_id=0, det_size=(640, 640))
|
119 |
|
120 |
# prepare models under ./checkpoints
|
121 |
+
face_adapter = f'data/checkpoints/ip-adapter.bin'
|
122 |
+
controlnet_path = f'data/checkpoints/ControlNetModel'
|
123 |
|
124 |
# load IdentityNet
|
125 |
st = time.time()
|
|
|
236 |
)
|
237 |
del weights_sd
|
238 |
del lora_model
|
239 |
+
#@spaces.GPU
|
240 |
def generate_image(prompt, negative, face_emb, face_image, face_kps, image_strength, guidance_scale, face_strength, depth_control_scale, repo_name, loaded_state_dict, lora_scale, sdxl_loras, selected_state_index, st):
|
241 |
print(loaded_state_dict)
|
242 |
et = time.time()
|
|
|
497 |
with gr.Blocks(css="custom.css") as demo:
|
498 |
gr_sdxl_loras = gr.State(value=sdxl_loras_raw)
|
499 |
title = gr.HTML(
|
500 |
+
"""<h1>
|
501 |
<span>Face to All<br><small style="
|
502 |
font-size: 13px;
|
503 |
display: block;
|
|
|
607 |
share_button.click(None, [], [], js=share_js)
|
608 |
demo.load(fn=classify_gallery, inputs=[gr_sdxl_loras], outputs=[gallery, gr_sdxl_loras], queue=False, js=js)
|
609 |
demo.queue(max_size=20)
|
610 |
+
demo.launch(share=True)
|
requirements.txt
CHANGED
@@ -6,7 +6,8 @@ insightface
|
|
6 |
controlnet_aux
|
7 |
timm==0.6.7
|
8 |
gdown
|
9 |
-
onnxruntime-gpu
|
10 |
peft
|
11 |
compel
|
12 |
-
gradio_imageslider
|
|
|
|
6 |
controlnet_aux
|
7 |
timm==0.6.7
|
8 |
gdown
|
9 |
+
#onnxruntime-gpu
|
10 |
peft
|
11 |
compel
|
12 |
+
gradio_imageslider
|
13 |
+
gradio
|