Upload app.py
Browse files
app.py
CHANGED
@@ -59,10 +59,10 @@ def change_base_model(repo_id: str, cn_on: bool):
|
|
59 |
#progress(0, desc=f"Loading model: {repo_id} / Loading ControlNet: {controlnet_model_union_repo}")
|
60 |
print(f"Loading model: {repo_id} / Loading ControlNet: {controlnet_model_union_repo}")
|
61 |
clear_cache()
|
62 |
-
controlnet_union = FluxControlNetModel.from_pretrained(controlnet_model_union_repo, torch_dtype=dtype)
|
63 |
-
controlnet = FluxMultiControlNetModel([controlnet_union])
|
64 |
-
pipe = FluxControlNetPipeline.from_pretrained(repo_id, controlnet=controlnet, torch_dtype=dtype
|
65 |
-
pipe.flux_pipe_call_that_returns_an_iterable_of_images = flux_pipe_call_that_returns_an_iterable_of_images.__get__(pipe)
|
66 |
last_model = repo_id
|
67 |
last_cn_on = cn_on
|
68 |
#progress(1, desc=f"Model loaded: {repo_id} / ControlNet Loaded: {controlnet_model_union_repo}")
|
@@ -71,7 +71,7 @@ def change_base_model(repo_id: str, cn_on: bool):
|
|
71 |
#progress(0, desc=f"Loading model: {repo_id}")
|
72 |
print(f"Loading model: {repo_id}")
|
73 |
clear_cache()
|
74 |
-
pipe = DiffusionPipeline.from_pretrained(repo_id, torch_dtype=dtype, vae=taef1)
|
75 |
pipe.flux_pipe_call_that_returns_an_iterable_of_images = flux_pipe_call_that_returns_an_iterable_of_images.__get__(pipe)
|
76 |
last_model = repo_id
|
77 |
last_cn_on = cn_on
|
@@ -154,7 +154,7 @@ def generate_image(prompt_mash, steps, seed, cfg_scale, width, height, lora_scal
|
|
154 |
progress(0, desc="Start Inference with ControlNet.")
|
155 |
if controlnet is not None: controlnet.to("cuda")
|
156 |
if controlnet_union is not None: controlnet_union.to("cuda")
|
157 |
-
for img in pipe
|
158 |
prompt=prompt_mash,
|
159 |
control_image=images,
|
160 |
control_mode=modes,
|
@@ -165,9 +165,7 @@ def generate_image(prompt_mash, steps, seed, cfg_scale, width, height, lora_scal
|
|
165 |
controlnet_conditioning_scale=scales,
|
166 |
generator=generator,
|
167 |
joint_attention_kwargs={"scale": lora_scale},
|
168 |
-
|
169 |
-
good_vae=good_vae,
|
170 |
-
):
|
171 |
yield img
|
172 |
except Exception as e:
|
173 |
print(e)
|
|
|
59 |
#progress(0, desc=f"Loading model: {repo_id} / Loading ControlNet: {controlnet_model_union_repo}")
|
60 |
print(f"Loading model: {repo_id} / Loading ControlNet: {controlnet_model_union_repo}")
|
61 |
clear_cache()
|
62 |
+
controlnet_union = FluxControlNetModel.from_pretrained(controlnet_model_union_repo, torch_dtype=dtype)
|
63 |
+
controlnet = FluxMultiControlNetModel([controlnet_union])
|
64 |
+
pipe = FluxControlNetPipeline.from_pretrained(repo_id, controlnet=controlnet, torch_dtype=dtype)
|
65 |
+
#pipe.flux_pipe_call_that_returns_an_iterable_of_images = flux_pipe_call_that_returns_an_iterable_of_images.__get__(pipe)
|
66 |
last_model = repo_id
|
67 |
last_cn_on = cn_on
|
68 |
#progress(1, desc=f"Model loaded: {repo_id} / ControlNet Loaded: {controlnet_model_union_repo}")
|
|
|
71 |
#progress(0, desc=f"Loading model: {repo_id}")
|
72 |
print(f"Loading model: {repo_id}")
|
73 |
clear_cache()
|
74 |
+
pipe = DiffusionPipeline.from_pretrained(repo_id, torch_dtype=dtype, vae=taef1)
|
75 |
pipe.flux_pipe_call_that_returns_an_iterable_of_images = flux_pipe_call_that_returns_an_iterable_of_images.__get__(pipe)
|
76 |
last_model = repo_id
|
77 |
last_cn_on = cn_on
|
|
|
154 |
progress(0, desc="Start Inference with ControlNet.")
|
155 |
if controlnet is not None: controlnet.to("cuda")
|
156 |
if controlnet_union is not None: controlnet_union.to("cuda")
|
157 |
+
for img in pipe(
|
158 |
prompt=prompt_mash,
|
159 |
control_image=images,
|
160 |
control_mode=modes,
|
|
|
165 |
controlnet_conditioning_scale=scales,
|
166 |
generator=generator,
|
167 |
joint_attention_kwargs={"scale": lora_scale},
|
168 |
+
).images:
|
|
|
|
|
169 |
yield img
|
170 |
except Exception as e:
|
171 |
print(e)
|