John6666 commited on
Commit
a138792
1 Parent(s): 8ac6201

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +4 -4
  2. mod.py +1 -1
app.py CHANGED
@@ -44,7 +44,7 @@ def change_base_model(repo_id: str, cn_on: bool, progress=gr.Progress(track_tqdm
44
  controlnet_union = FluxControlNetModel.from_pretrained(controlnet_model_union_repo, torch_dtype=torch.bfloat16)
45
  controlnet = FluxMultiControlNetModel([controlnet_union])
46
  pipe = FluxControlNetPipeline.from_pretrained(repo_id, controlnet=controlnet, torch_dtype=torch.bfloat16)
47
- pipe.enable_model_cpu_offload()
48
  last_model = repo_id
49
  last_cn_on = cn_on
50
  progress(1, desc=f"Model loaded: {repo_id} / ControlNet Loaded: {controlnet_model_union_repo}")
@@ -54,7 +54,7 @@ def change_base_model(repo_id: str, cn_on: bool, progress=gr.Progress(track_tqdm
54
  print(f"Loading model: {repo_id}")
55
  clear_cache()
56
  pipe = DiffusionPipeline.from_pretrained(repo_id, torch_dtype=torch.bfloat16)
57
- pipe.enable_model_cpu_offload()
58
  last_model = repo_id
59
  last_cn_on = cn_on
60
  progress(1, desc=f"Model loaded: {repo_id}")
@@ -321,7 +321,7 @@ with gr.Blocks(theme='Nymbo/Nymbo_Theme', fill_width=True, css=css) as app:
321
  custom_lora_info = gr.HTML(visible=False)
322
  custom_lora_button = gr.Button("Remove custom LoRA", visible=False)
323
  with gr.Column(scale=4):
324
- result = gr.Image(label="Generated Image")
325
 
326
  with gr.Row():
327
  with gr.Accordion("Advanced Settings", open=False):
@@ -394,7 +394,7 @@ with gr.Blocks(theme='Nymbo/Nymbo_Theme', fill_width=True, css=css) as app:
394
  cn_scale[i] = gr.Slider(label=f"ControlNet {int(i+1)} Weight", minimum=0.0, maximum=1.0, step=0.01, value=0.75)
395
  cn_res[i] = gr.Slider(label=f"ControlNet {int(i+1)} Preprocess resolution", minimum=128, maximum=512, value=384, step=1)
396
  cn_num[i] = gr.Number(i, visible=False)
397
- cn_image[i] = gr.Image(type="pil", label="Control Image", height=256)
398
 
399
  gallery.select(
400
  update_selection,
 
44
  controlnet_union = FluxControlNetModel.from_pretrained(controlnet_model_union_repo, torch_dtype=torch.bfloat16)
45
  controlnet = FluxMultiControlNetModel([controlnet_union])
46
  pipe = FluxControlNetPipeline.from_pretrained(repo_id, controlnet=controlnet, torch_dtype=torch.bfloat16)
47
+ #pipe.enable_model_cpu_offload()
48
  last_model = repo_id
49
  last_cn_on = cn_on
50
  progress(1, desc=f"Model loaded: {repo_id} / ControlNet Loaded: {controlnet_model_union_repo}")
 
54
  print(f"Loading model: {repo_id}")
55
  clear_cache()
56
  pipe = DiffusionPipeline.from_pretrained(repo_id, torch_dtype=torch.bfloat16)
57
+ #pipe.enable_model_cpu_offload()
58
  last_model = repo_id
59
  last_cn_on = cn_on
60
  progress(1, desc=f"Model loaded: {repo_id}")
 
321
  custom_lora_info = gr.HTML(visible=False)
322
  custom_lora_button = gr.Button("Remove custom LoRA", visible=False)
323
  with gr.Column(scale=4):
324
+ result = gr.Image(label="Generated Image", format="png", show_share_button=False)
325
 
326
  with gr.Row():
327
  with gr.Accordion("Advanced Settings", open=False):
 
394
  cn_scale[i] = gr.Slider(label=f"ControlNet {int(i+1)} Weight", minimum=0.0, maximum=1.0, step=0.01, value=0.75)
395
  cn_res[i] = gr.Slider(label=f"ControlNet {int(i+1)} Preprocess resolution", minimum=128, maximum=512, value=384, step=1)
396
  cn_num[i] = gr.Number(i, visible=False)
397
+ cn_image[i] = gr.Image(type="pil", label="Control Image", height=256, show_share_button=False)
398
 
399
  gallery.select(
400
  update_selection,
mod.py CHANGED
@@ -148,7 +148,7 @@ def preprocess_image(image: Image.Image, control_mode: str, height: int, width:
148
  preprocess_resolution: int, progress=gr.Progress(track_tqdm=True)):
149
  if control_mode == "None": return image
150
  image_resolution = max(width, height)
151
- image_before = resize_image(expand2square(image), image_resolution, image_resolution, False)
152
  # generated control_
153
  print("start to generate control image")
154
  preprocessor = Preprocessor()
 
148
  preprocess_resolution: int, progress=gr.Progress(track_tqdm=True)):
149
  if control_mode == "None": return image
150
  image_resolution = max(width, height)
151
+ image_before = resize_image(expand2square(image.convert("RGB")), image_resolution, image_resolution, False)
152
  # generated control_
153
  print("start to generate control image")
154
  preprocessor = Preprocessor()