Spaces:
Running
on
Zero
Running
on
Zero
use face model rather than building it each time from source images
Browse files
app.py
CHANGED
@@ -39,6 +39,17 @@ hf_hub_download(
|
|
39 |
filename="codeformer-v0.1.0.pth",
|
40 |
local_dir="models/facerestore_models",
|
41 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
|
43 |
# ReActor has its own special snowflake installation
|
44 |
os.system("cd custom_nodes/ComfyUI-ReActor && python install.py")
|
@@ -69,10 +80,12 @@ def import_custom_nodes() -> None:
|
|
69 |
|
70 |
# Preload nodes, models.
|
71 |
import_custom_nodes()
|
72 |
-
load_images_node = NODE_CLASS_MAPPINGS["LoadImagesFromFolderKJ"]()
|
73 |
loadimage = NODE_CLASS_MAPPINGS["LoadImage"]()
|
74 |
upscalemodelloader = NODE_CLASS_MAPPINGS["UpscaleModelLoader"]()
|
75 |
-
|
|
|
|
|
|
|
76 |
imageresize = NODE_CLASS_MAPPINGS["ImageResize+"]()
|
77 |
reactorfaceswap = NODE_CLASS_MAPPINGS["ReActorFaceSwap"]()
|
78 |
imageupscalewithmodel = NODE_CLASS_MAPPINGS["ImageUpscaleWithModel"]()
|
@@ -202,28 +215,10 @@ add_extra_model_paths()
|
|
202 |
@spaces.GPU(duration=60)
|
203 |
def advance_blur(input_image):
|
204 |
with torch.inference_mode():
|
205 |
-
source_images_batch = load_images_node.load_images(
|
206 |
-
folder="source_faces/",
|
207 |
-
width=1024,
|
208 |
-
height=1024,
|
209 |
-
keep_aspect_ratio="crop",
|
210 |
-
image_load_cap=0,
|
211 |
-
start_index=0,
|
212 |
-
include_subfolders=False,
|
213 |
-
)
|
214 |
-
|
215 |
loaded_input_image = loadimage.load_image(
|
216 |
image=input_image,
|
217 |
)
|
218 |
|
219 |
-
face_model = reactorbuildfacemodel.blend_faces(
|
220 |
-
save_mode=True,
|
221 |
-
send_only=False,
|
222 |
-
face_model_name="default",
|
223 |
-
compute_method="Mean",
|
224 |
-
images=get_value_at_index(source_images_batch, 0),
|
225 |
-
)
|
226 |
-
|
227 |
resized_input_image = imageresize.execute(
|
228 |
width=2560,
|
229 |
height=2560,
|
|
|
39 |
filename="codeformer-v0.1.0.pth",
|
40 |
local_dir="models/facerestore_models",
|
41 |
)
|
42 |
+
hf_hub_download(
|
43 |
+
repo_id="darkeril/collection ",
|
44 |
+
filename="detection_Resnet50_Final.pth",
|
45 |
+
local_dir="models/facedetection",
|
46 |
+
)
|
47 |
+
hf_hub_download(
|
48 |
+
repo_id="model2/advance_face_model",
|
49 |
+
filename="advance_face_model.safetensors",
|
50 |
+
local_dir="models/reactor/face_models",
|
51 |
+
)
|
52 |
+
|
53 |
|
54 |
# ReActor has its own special snowflake installation
|
55 |
os.system("cd custom_nodes/ComfyUI-ReActor && python install.py")
|
|
|
80 |
|
81 |
# Preload nodes, models.
|
82 |
import_custom_nodes()
|
|
|
83 |
loadimage = NODE_CLASS_MAPPINGS["LoadImage"]()
|
84 |
upscalemodelloader = NODE_CLASS_MAPPINGS["UpscaleModelLoader"]()
|
85 |
+
reactorloadfacemodel = NODE_CLASS_MAPPINGS["ReActorLoadFaceModel"]()
|
86 |
+
face_model = reactorloadfacemodel.load_model(
|
87 |
+
face_model="advance_face_model.safetensors"
|
88 |
+
)
|
89 |
imageresize = NODE_CLASS_MAPPINGS["ImageResize+"]()
|
90 |
reactorfaceswap = NODE_CLASS_MAPPINGS["ReActorFaceSwap"]()
|
91 |
imageupscalewithmodel = NODE_CLASS_MAPPINGS["ImageUpscaleWithModel"]()
|
|
|
215 |
@spaces.GPU(duration=60)
|
216 |
def advance_blur(input_image):
|
217 |
with torch.inference_mode():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
218 |
loaded_input_image = loadimage.load_image(
|
219 |
image=input_image,
|
220 |
)
|
221 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
222 |
resized_input_image = imageresize.execute(
|
223 |
width=2560,
|
224 |
height=2560,
|