primerz commited on
Commit
31c79b1
·
verified ·
1 Parent(s): d8780fa

Update generator.py

Browse files
Files changed (1) hide show
  1. generator.py +23 -10
generator.py CHANGED
@@ -26,7 +26,16 @@ class Generator:
26
 
27
  return depth_map, lineart_map
28
 
29
- def predict(self, input_image, user_prompt=""):
 
 
 
 
 
 
 
 
 
30
  # 1. Pre-process Inputs
31
  print("Processing Input...")
32
  processed_image = resize_image_to_1mp(input_image)
@@ -56,12 +65,14 @@ class Generator:
56
  # ControlNet order: [InstantID, Zoe, LineArt]
57
  if face_emb is not None:
58
  print("Face detected: Applying InstantID.")
59
- controlnet_conditioning_scale = [0.6, 0.3, 0.3]
 
60
  control_guidance_end = [0.3, 0.6, 0.6] # Stop InstantID early
61
  self.mh.pipeline.set_ip_adapter_scale(0.6) # Set IP-Adapter (likeness) strength
62
  else:
63
  print("No face detected: Disabling InstantID.")
64
- controlnet_conditioning_scale = [0.0, 0.3, 0.3] # Disable InstantID weight
 
65
  control_guidance_end = [0.3, 0.6, 0.6]
66
  self.mh.pipeline.set_ip_adapter_scale(0.0)
67
 
@@ -79,18 +90,20 @@ class Generator:
79
  control_image=[processed_image, depth_map, lineart_map], # ControlNet inputs
80
  image_embeds=face_emb, # Face embedding (or dummy)
81
 
82
- strength=0.3, # <-- Img2Img strength
 
 
 
 
 
83
  controlnet_conditioning_scale=controlnet_conditioning_scale,
84
  control_guidance_end=control_guidance_end,
85
 
86
- # LCM settings
87
- num_inference_steps=6,
88
- guidance_scale=1.5, # <-- CFG Scale
89
-
90
  clip_skip=2,
91
 
92
- # --- LoRA Strength ---
93
- cross_attention_kwargs={"scale": 1.25}
 
94
 
95
  ).images[0]
96
 
 
26
 
27
  return depth_map, lineart_map
28
 
29
+ def predict(
30
+ self,
31
+ input_image,
32
+ user_prompt="",
33
+ guidance_scale=1.5,
34
+ num_inference_steps=6,
35
+ img2img_strength=0.3,
36
+ depth_strength=0.3,
37
+ lineart_strength=0.3
38
+ ):
39
  # 1. Pre-process Inputs
40
  print("Processing Input...")
41
  processed_image = resize_image_to_1mp(input_image)
 
65
  # ControlNet order: [InstantID, Zoe, LineArt]
66
  if face_emb is not None:
67
  print("Face detected: Applying InstantID.")
68
+ # Use strengths from UI
69
+ controlnet_conditioning_scale = [0.6, depth_strength, lineart_strength]
70
  control_guidance_end = [0.3, 0.6, 0.6] # Stop InstantID early
71
  self.mh.pipeline.set_ip_adapter_scale(0.6) # Set IP-Adapter (likeness) strength
72
  else:
73
  print("No face detected: Disabling InstantID.")
74
+ # Use strengths from UI, but keep InstantID at 0.0
75
+ controlnet_conditioning_scale = [0.0, depth_strength, lineart_strength]
76
  control_guidance_end = [0.3, 0.6, 0.6]
77
  self.mh.pipeline.set_ip_adapter_scale(0.0)
78
 
 
90
  control_image=[processed_image, depth_map, lineart_map], # ControlNet inputs
91
  image_embeds=face_emb, # Face embedding (or dummy)
92
 
93
+ # --- Parameters from UI ---
94
+ strength=img2img_strength,
95
+ num_inference_steps=num_inference_steps,
96
+ guidance_scale=guidance_scale,
97
+ # --- End Parameters from UI ---
98
+
99
  controlnet_conditioning_scale=controlnet_conditioning_scale,
100
  control_guidance_end=control_guidance_end,
101
 
 
 
 
 
102
  clip_skip=2,
103
 
104
+ # --- LoRA Strength REMOVED ---
105
+ # No longer needed, as LoRA is fused into the model weights
106
+ # cross_attention_kwargs={"scale": 1.25}
107
 
108
  ).images[0]
109