Spaces:
Running
on
Zero
Running
on
Zero
Upload 2 files
Browse files
app.py
CHANGED
@@ -38,15 +38,16 @@ def change_base_model(repo_id: str, cn_on: bool, progress=gr.Progress(track_tqdm
|
|
38 |
global controlnet
|
39 |
global last_model
|
40 |
global last_cn_on
|
|
|
41 |
try:
|
42 |
if (repo_id == last_model and cn_on is last_cn_on) or not is_repo_name(repo_id) or not is_repo_exists(repo_id): return
|
43 |
if cn_on:
|
44 |
progress(0, desc=f"Loading model: {repo_id} / Loading ControlNet: {controlnet_model_union_repo}")
|
45 |
print(f"Loading model: {repo_id} / Loading ControlNet: {controlnet_model_union_repo}")
|
46 |
clear_cache()
|
47 |
-
controlnet_union = FluxControlNetModel.from_pretrained(controlnet_model_union_repo, torch_dtype=
|
48 |
controlnet = FluxMultiControlNetModel([controlnet_union])
|
49 |
-
pipe = FluxControlNetPipeline.from_pretrained(repo_id, controlnet=controlnet, torch_dtype=
|
50 |
#pipe.enable_model_cpu_offload()
|
51 |
last_model = repo_id
|
52 |
last_cn_on = cn_on
|
@@ -56,7 +57,7 @@ def change_base_model(repo_id: str, cn_on: bool, progress=gr.Progress(track_tqdm
|
|
56 |
progress(0, desc=f"Loading model: {repo_id}")
|
57 |
print(f"Loading model: {repo_id}")
|
58 |
clear_cache()
|
59 |
-
pipe = DiffusionPipeline.from_pretrained(repo_id, torch_dtype=
|
60 |
#pipe.enable_model_cpu_offload()
|
61 |
last_model = repo_id
|
62 |
last_cn_on = cn_on
|
@@ -113,6 +114,8 @@ def update_selection(evt: gr.SelectData, width, height):
|
|
113 |
@spaces.GPU(duration=70)
|
114 |
def generate_image(prompt_mash, steps, seed, cfg_scale, width, height, lora_scale, cn_on, progress=gr.Progress(track_tqdm=True)):
|
115 |
pipe.to("cuda")
|
|
|
|
|
116 |
generator = torch.Generator(device="cuda").manual_seed(seed)
|
117 |
|
118 |
with calculateDuration("Generating image"):
|
@@ -145,6 +148,7 @@ def generate_image(prompt_mash, steps, seed, cfg_scale, width, height, lora_scal
|
|
145 |
joint_attention_kwargs={"scale": lora_scale},
|
146 |
).images[0]
|
147 |
except Exception as e:
|
|
|
148 |
print(e)
|
149 |
raise Exception(f"Inference Error: {e}")
|
150 |
return image
|
|
|
38 |
global controlnet
|
39 |
global last_model
|
40 |
global last_cn_on
|
41 |
+
dtype = torch.bfloat16
|
42 |
try:
|
43 |
if (repo_id == last_model and cn_on is last_cn_on) or not is_repo_name(repo_id) or not is_repo_exists(repo_id): return
|
44 |
if cn_on:
|
45 |
progress(0, desc=f"Loading model: {repo_id} / Loading ControlNet: {controlnet_model_union_repo}")
|
46 |
print(f"Loading model: {repo_id} / Loading ControlNet: {controlnet_model_union_repo}")
|
47 |
clear_cache()
|
48 |
+
controlnet_union = FluxControlNetModel.from_pretrained(controlnet_model_union_repo, torch_dtype=dtype)
|
49 |
controlnet = FluxMultiControlNetModel([controlnet_union])
|
50 |
+
pipe = FluxControlNetPipeline.from_pretrained(repo_id, controlnet=controlnet, torch_dtype=dtype)
|
51 |
#pipe.enable_model_cpu_offload()
|
52 |
last_model = repo_id
|
53 |
last_cn_on = cn_on
|
|
|
57 |
progress(0, desc=f"Loading model: {repo_id}")
|
58 |
print(f"Loading model: {repo_id}")
|
59 |
clear_cache()
|
60 |
+
pipe = DiffusionPipeline.from_pretrained(repo_id, torch_dtype=dtype)
|
61 |
#pipe.enable_model_cpu_offload()
|
62 |
last_model = repo_id
|
63 |
last_cn_on = cn_on
|
|
|
114 |
@spaces.GPU(duration=70)
|
115 |
def generate_image(prompt_mash, steps, seed, cfg_scale, width, height, lora_scale, cn_on, progress=gr.Progress(track_tqdm=True)):
|
116 |
pipe.to("cuda")
|
117 |
+
controlnet.to("cuda")
|
118 |
+
controlnet_union.to("cuda")
|
119 |
generator = torch.Generator(device="cuda").manual_seed(seed)
|
120 |
|
121 |
with calculateDuration("Generating image"):
|
|
|
148 |
joint_attention_kwargs={"scale": lora_scale},
|
149 |
).images[0]
|
150 |
except Exception as e:
|
151 |
+
progress(1, desc=f"Inference Error: {e}")
|
152 |
print(e)
|
153 |
raise Exception(f"Inference Error: {e}")
|
154 |
return image
|
mod.py
CHANGED
@@ -19,6 +19,7 @@ models = [
|
|
19 |
"black-forest-labs/FLUX.1-schnell",
|
20 |
"sayakpaul/FLUX.1-merged",
|
21 |
"John6666/hyper-flux1-dev-fp8-flux",
|
|
|
22 |
"John6666/blue-pencil-flux1-v001-fp8-flux",
|
23 |
"John6666/copycat-flux-test-fp8-v11-fp8-flux",
|
24 |
"John6666/nepotism-fuxdevschnell-v3aio-fp8-flux",
|
@@ -26,6 +27,7 @@ models = [
|
|
26 |
"John6666/lyh-dalle-anime-v12dalle-fp8-flux",
|
27 |
"John6666/fluxunchained-artfulnsfw-fut516xfp8e4m3fnv11-fp8-flux",
|
28 |
"John6666/fastflux-unchained-t5f16-fp8-flux",
|
|
|
29 |
"John6666/the-araminta-flux1a1-fp8-flux",
|
30 |
"John6666/acorn-is-spinning-flux-v11-fp8-flux",
|
31 |
"John6666/fluxescore-dev-v10fp16-fp8-flux",
|
|
|
19 |
"black-forest-labs/FLUX.1-schnell",
|
20 |
"sayakpaul/FLUX.1-merged",
|
21 |
"John6666/hyper-flux1-dev-fp8-flux",
|
22 |
+
"John6666/flux1-dev-minus-v1-fp8-flux",
|
23 |
"John6666/blue-pencil-flux1-v001-fp8-flux",
|
24 |
"John6666/copycat-flux-test-fp8-v11-fp8-flux",
|
25 |
"John6666/nepotism-fuxdevschnell-v3aio-fp8-flux",
|
|
|
27 |
"John6666/lyh-dalle-anime-v12dalle-fp8-flux",
|
28 |
"John6666/fluxunchained-artfulnsfw-fut516xfp8e4m3fnv11-fp8-flux",
|
29 |
"John6666/fastflux-unchained-t5f16-fp8-flux",
|
30 |
+
"John6666/iniverse-mix-xl-sfwnsfw-fluxdfp8v10-fp8-flux",
|
31 |
"John6666/the-araminta-flux1a1-fp8-flux",
|
32 |
"John6666/acorn-is-spinning-flux-v11-fp8-flux",
|
33 |
"John6666/fluxescore-dev-v10fp16-fp8-flux",
|