John6666 commited on
Commit
de9e464
·
verified ·
1 Parent(s): f94e58e

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -48,7 +48,7 @@ pipe.flux_pipe_call_that_returns_an_iterable_of_images = flux_pipe_call_that_ret
48
  # https://huggingface.co/InstantX/FLUX.1-dev-Controlnet-Union
49
  # https://huggingface.co/spaces/jiuface/FLUX.1-dev-Controlnet-Union
50
  @spaces.GPU()
51
- def change_base_model(repo_id: str, cn_on: bool):
52
  global pipe
53
  global controlnet_union
54
  global controlnet
@@ -59,7 +59,7 @@ def change_base_model(repo_id: str, cn_on: bool):
59
  if cn_on:
60
  #progress(0, desc=f"Loading model: {repo_id} / Loading ControlNet: {controlnet_model_union_repo}")
61
  print(f"Loading model: {repo_id} / Loading ControlNet: {controlnet_model_union_repo}")
62
- clear_cache()
63
  controlnet_union = FluxControlNetModel.from_pretrained(controlnet_model_union_repo, torch_dtype=dtype).to(device)
64
  controlnet = FluxMultiControlNetModel([controlnet_union]).to(device)
65
  pipe = FluxControlNetPipeline.from_pretrained(repo_id, controlnet=controlnet, torch_dtype=dtype).to(device)
@@ -71,7 +71,7 @@ def change_base_model(repo_id: str, cn_on: bool):
71
  else:
72
  #progress(0, desc=f"Loading model: {repo_id}")
73
  print(f"Loading model: {repo_id}")
74
- clear_cache()
75
  pipe = DiffusionPipeline.from_pretrained(repo_id, torch_dtype=dtype, vae=taef1).to(device)
76
  pipe.flux_pipe_call_that_returns_an_iterable_of_images = flux_pipe_call_that_returns_an_iterable_of_images.__get__(pipe)
77
  last_model = repo_id
 
48
  # https://huggingface.co/InstantX/FLUX.1-dev-Controlnet-Union
49
  # https://huggingface.co/spaces/jiuface/FLUX.1-dev-Controlnet-Union
50
  @spaces.GPU()
51
+ def change_base_model(repo_id: str, cn_on: bool, progress=gr.Progress(track_tqdm=True)):
52
  global pipe
53
  global controlnet_union
54
  global controlnet
 
59
  if cn_on:
60
  #progress(0, desc=f"Loading model: {repo_id} / Loading ControlNet: {controlnet_model_union_repo}")
61
  print(f"Loading model: {repo_id} / Loading ControlNet: {controlnet_model_union_repo}")
62
+ #clear_cache()
63
  controlnet_union = FluxControlNetModel.from_pretrained(controlnet_model_union_repo, torch_dtype=dtype).to(device)
64
  controlnet = FluxMultiControlNetModel([controlnet_union]).to(device)
65
  pipe = FluxControlNetPipeline.from_pretrained(repo_id, controlnet=controlnet, torch_dtype=dtype).to(device)
 
71
  else:
72
  #progress(0, desc=f"Loading model: {repo_id}")
73
  print(f"Loading model: {repo_id}")
74
+ #clear_cache()
75
  pipe = DiffusionPipeline.from_pretrained(repo_id, torch_dtype=dtype, vae=taef1).to(device)
76
  pipe.flux_pipe_call_that_returns_an_iterable_of_images = flux_pipe_call_that_returns_an_iterable_of_images.__get__(pipe)
77
  last_model = repo_id