Spaces:
Running
on
Zero
Running
on
Zero
Update generator.py
Browse files- generator.py +6 -7
generator.py
CHANGED
|
@@ -34,6 +34,7 @@ class Generator:
|
|
| 34 |
guidance_scale=1.5,
|
| 35 |
num_inference_steps=6,
|
| 36 |
img2img_strength=0.3,
|
|
|
|
| 37 |
depth_strength=0.3,
|
| 38 |
lineart_strength=0.3,
|
| 39 |
seed=-1
|
|
@@ -82,26 +83,24 @@ class Generator:
|
|
| 82 |
|
| 83 |
# Create keypoint image
|
| 84 |
face_kps = draw_kps(processed_image, face_info['kps'])
|
| 85 |
-
face_guidance = (depth_strength + lineart_strength) / 2
|
| 86 |
-
|
| 87 |
# Set strengths (using 0.8 from file's example)
|
| 88 |
-
controlnet_conditioning_scale = [
|
| 89 |
-
self.mh.pipeline.set_ip_adapter_scale(
|
| 90 |
else:
|
| 91 |
print("No face detected: Disabling InstantID.")
|
| 92 |
# Create dummy embedding
|
| 93 |
face_emb = torch.zeros((1, 512), dtype=Config.DTYPE, device=Config.DEVICE)
|
| 94 |
# Create dummy keypoint image (black)
|
| 95 |
face_kps = Image.new('RGB', (target_width, target_height), (0, 0, 0))
|
| 96 |
-
face_guidance = 0.001
|
| 97 |
face_kps_guidance_end = 0.001
|
|
|
|
| 98 |
|
| 99 |
# Set strengths
|
| 100 |
controlnet_conditioning_scale = [0.0, depth_strength, lineart_strength]
|
| 101 |
self.mh.pipeline.set_ip_adapter_scale(0.0)
|
| 102 |
|
| 103 |
# We keep the guidance_end for pose low
|
| 104 |
-
control_guidance_end = [
|
| 105 |
|
| 106 |
# --- Seed/Generator Logic ---
|
| 107 |
if seed == -1 or seed is None:
|
|
@@ -129,7 +128,7 @@ class Generator:
|
|
| 129 |
controlnet_conditioning_scale=controlnet_conditioning_scale,
|
| 130 |
control_guidance_end=control_guidance_end,
|
| 131 |
|
| 132 |
-
clip_skip=
|
| 133 |
|
| 134 |
).images[0]
|
| 135 |
|
|
|
|
| 34 |
guidance_scale=1.5,
|
| 35 |
num_inference_steps=6,
|
| 36 |
img2img_strength=0.3,
|
| 37 |
+
face_strength=0.3,
|
| 38 |
depth_strength=0.3,
|
| 39 |
lineart_strength=0.3,
|
| 40 |
seed=-1
|
|
|
|
| 83 |
|
| 84 |
# Create keypoint image
|
| 85 |
face_kps = draw_kps(processed_image, face_info['kps'])
|
|
|
|
|
|
|
| 86 |
# Set strengths (using 0.8 from file's example)
|
| 87 |
+
controlnet_conditioning_scale = [face_strength, depth_strength, lineart_strength]
|
| 88 |
+
self.mh.pipeline.set_ip_adapter_scale(0.75)
|
| 89 |
else:
|
| 90 |
print("No face detected: Disabling InstantID.")
|
| 91 |
# Create dummy embedding
|
| 92 |
face_emb = torch.zeros((1, 512), dtype=Config.DTYPE, device=Config.DEVICE)
|
| 93 |
# Create dummy keypoint image (black)
|
| 94 |
face_kps = Image.new('RGB', (target_width, target_height), (0, 0, 0))
|
|
|
|
| 95 |
face_kps_guidance_end = 0.001
|
| 96 |
+
face_strength_end = 0.001
|
| 97 |
|
| 98 |
# Set strengths
|
| 99 |
controlnet_conditioning_scale = [0.0, depth_strength, lineart_strength]
|
| 100 |
self.mh.pipeline.set_ip_adapter_scale(0.0)
|
| 101 |
|
| 102 |
# We keep the guidance_end for pose low
|
| 103 |
+
control_guidance_end = [face_strength * 0.90, depth_strength * 0.70, lineart_strength * 0.80]
|
| 104 |
|
| 105 |
# --- Seed/Generator Logic ---
|
| 106 |
if seed == -1 or seed is None:
|
|
|
|
| 128 |
controlnet_conditioning_scale=controlnet_conditioning_scale,
|
| 129 |
control_guidance_end=control_guidance_end,
|
| 130 |
|
| 131 |
+
clip_skip=2,
|
| 132 |
|
| 133 |
).images[0]
|
| 134 |
|