Tanut commited on
Commit
9c3d0dc
·
1 Parent(s): 2500ffd
Files changed (1) hide show
  1. app.py +15 -0
app.py CHANGED
@@ -141,6 +141,20 @@ def qr_stylize(url: str, style_prompt: str, negative: str, steps: int, cfg: floa
141
  gc.collect()
142
 
143
  with torch.autocast(device_type="cuda", dtype=DTYPE):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
144
  out = pipe(
145
  prompt=str(style_prompt),
146
  negative_prompt=str(negative or ""),
@@ -151,6 +165,7 @@ def qr_stylize(url: str, style_prompt: str, negative: str, steps: int, cfg: floa
151
  width=s, height=s,
152
  generator=gen,
153
  )
 
154
  img = out.images[0]
155
  img = enforce_qr_contrast(img, qr_img, strength=float(repair_strength), feather=float(feather))
156
  return img, qr_img
 
141
  gc.collect()
142
 
143
  with torch.autocast(device_type="cuda", dtype=DTYPE):
144
+ try:
145
+ # diffusers ≥ 0.30.x uses `image=` for ControlNet’s conditioning input
146
+ out = pipe(
147
+ prompt=str(style_prompt),
148
+ negative_prompt=str(negative or ""),
149
+ image=qr_img, # <-- use `image`
150
+ controlnet_conditioning_scale=float(qr_weight),
151
+ num_inference_steps=int(steps),
152
+ guidance_scale=float(cfg),
153
+ width=s, height=s,
154
+ generator=gen,
155
+ )
156
+ except TypeError:
157
+ # fallback for older versions that still expect `control_image=`
158
  out = pipe(
159
  prompt=str(style_prompt),
160
  negative_prompt=str(negative or ""),
 
165
  width=s, height=s,
166
  generator=gen,
167
  )
168
+
169
  img = out.images[0]
170
  img = enforce_qr_contrast(img, qr_img, strength=float(repair_strength), feather=float(feather))
171
  return img, qr_img