Skip to content

Commit 5049faa

Browse files
t2i update from demo
1 parent 93f71cc commit 5049faa

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

demo/realtime-img2img/img2img.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,21 @@ def predict(self, params: "Pipeline.InputParams") -> Image.Image:
287287
for i in range(len(current_cfg)):
288288
current_cfg[i]['control_image'] = params.image
289289
self.stream.update_stream_params(controlnet_config=current_cfg)
290+
# Also push T2I-Adapter control image in img2img when configured
291+
if self.has_t2i and params.image is not None:
292+
try:
293+
t2i_module = getattr(self.stream.stream, '_t2i_adapter_module', None)
294+
if t2i_module is not None:
295+
try:
296+
num = len(getattr(t2i_module, 'controlnets', []))
297+
except Exception:
298+
num = 0
299+
if num > 0:
300+
t2i_cfg = [{'control_image': params.image} for _ in range(num)]
301+
print("predict: updating T2I-Adapter control images for img2img")
302+
self.stream.update_stream_params(t2i_config=t2i_cfg)
303+
except Exception:
304+
pass
290305
output_image = self.stream(params.image)
291306
elif self.has_ipadapter:
292307
# IPAdapter mode: use PIL image for img2img

0 commit comments

Comments
 (0)