shgao commited on
Commit
8e53b73
β€’
1 Parent(s): d7ae2ef

update ifx

Browse files
Files changed (2) hide show
  1. sam2edit_demo.py +2 -4
  2. sam2edit_lora.py +6 -3
sam2edit_demo.py CHANGED
@@ -72,8 +72,6 @@ def create_demo_template(process, process_image_click=None, examples=None,
72
  label="Image Resolution", minimum=256, maximum=768, value=512, step=64)
73
  refine_image_resolution = gr.Slider(
74
  label="Image Resolution", minimum=256, maximum=8192, value=1024, step=64)
75
- strength = gr.Slider(
76
- label="Control Strength", minimum=0.0, maximum=2.0, value=1.0, step=0.01)
77
  guess_mode = gr.Checkbox(
78
  label='Guess Mode', value=False)
79
  detect_resolution = gr.Slider(
@@ -93,12 +91,12 @@ def create_demo_template(process, process_image_click=None, examples=None,
93
  result_text = gr.Text(label='BLIP2+Human Prompt Text')
94
 
95
  ips = [source_image_brush, enable_all_generate, mask_image, control_scale, enable_auto_prompt, a_prompt, n_prompt, num_samples, image_resolution,
96
- detect_resolution, ddim_steps, guess_mode, strength, scale, seed, eta, enable_tile, refine_alignment_ratio, refine_image_resolution]
97
  run_button.click(fn=process, inputs=ips, outputs=[
98
  result_gallery_refine, result_gallery_init, result_gallery_ref, result_text])
99
 
100
  ip_click = [origin_image, enable_all_generate, click_mask, control_scale, enable_auto_prompt, a_prompt, n_prompt, num_samples, image_resolution,
101
- detect_resolution, ddim_steps, guess_mode, strength, scale, seed, eta, enable_tile, refine_alignment_ratio, refine_image_resolution]
102
 
103
  run_button_click.click(fn=process,
104
  inputs=ip_click,
 
72
  label="Image Resolution", minimum=256, maximum=768, value=512, step=64)
73
  refine_image_resolution = gr.Slider(
74
  label="Image Resolution", minimum=256, maximum=8192, value=1024, step=64)
 
 
75
  guess_mode = gr.Checkbox(
76
  label='Guess Mode', value=False)
77
  detect_resolution = gr.Slider(
 
91
  result_text = gr.Text(label='BLIP2+Human Prompt Text')
92
 
93
  ips = [source_image_brush, enable_all_generate, mask_image, control_scale, enable_auto_prompt, a_prompt, n_prompt, num_samples, image_resolution,
94
+ detect_resolution, ddim_steps, guess_mode, scale, seed, eta, enable_tile, refine_alignment_ratio, refine_image_resolution]
95
  run_button.click(fn=process, inputs=ips, outputs=[
96
  result_gallery_refine, result_gallery_init, result_gallery_ref, result_text])
97
 
98
  ip_click = [origin_image, enable_all_generate, click_mask, control_scale, enable_auto_prompt, a_prompt, n_prompt, num_samples, image_resolution,
99
+ detect_resolution, ddim_steps, guess_mode, scale, seed, eta, enable_tile, refine_alignment_ratio, refine_image_resolution]
100
 
101
  run_button_click.click(fn=process,
102
  inputs=ip_click,
sam2edit_lora.py CHANGED
@@ -256,7 +256,7 @@ def obtain_generation_model(base_model_path, lora_model_path, controlnet_path, g
256
  'lllyasviel/control_v11p_sd15_inpaint', torch_dtype=torch.float16) # inpainting controlnet
257
  )
258
 
259
- if generation_only:
260
  pipe = StableDiffusionControlNetPipeline.from_pretrained(
261
  base_model_path, controlnet=controlnet, torch_dtype=torch.float16, safety_checker=None
262
  )
@@ -466,7 +466,7 @@ class EditAnythingLoraModel:
466
  control_scale,
467
  enable_auto_prompt, a_prompt, n_prompt,
468
  num_samples, image_resolution, detect_resolution,
469
- ddim_steps, guess_mode, strength, scale, seed, eta,
470
  enable_tile=True, refine_alignment_ratio=None, refine_image_resolution=None, condition_model=None):
471
 
472
  if condition_model is None:
@@ -544,7 +544,7 @@ class EditAnythingLoraModel:
544
  prompt_embeds = torch.cat([prompt_embeds] * num_samples, dim=0)
545
  negative_prompt_embeds = torch.cat(
546
  [negative_prompt_embeds] * num_samples, dim=0)
547
- if enable_all_generate and not self.extra_inpaint:
548
  self.pipe.safety_checker = lambda images, clip_input: (
549
  images, False)
550
  x_samples = self.pipe(
@@ -556,6 +556,7 @@ class EditAnythingLoraModel:
556
  width=W,
557
  image=[control.type(torch.float16)],
558
  controlnet_conditioning_scale=[float(control_scale)],
 
559
  ).images
560
  else:
561
  multi_condition_image = []
@@ -579,6 +580,7 @@ class EditAnythingLoraModel:
579
  height=H,
580
  width=W,
581
  controlnet_conditioning_scale=multi_condition_scale,
 
582
  ).images
583
  results = [x_samples[i] for i in range(num_samples)]
584
 
@@ -605,6 +607,7 @@ class EditAnythingLoraModel:
605
  width=img_tile.size[0],
606
  controlnet_conditioning_scale=1.0,
607
  alignment_ratio=refine_alignment_ratio,
 
608
  ).images
609
  results_tile += x_samples_tile
610
 
 
256
  'lllyasviel/control_v11p_sd15_inpaint', torch_dtype=torch.float16) # inpainting controlnet
257
  )
258
 
259
+ if generation_only and extra_inpaint:
260
  pipe = StableDiffusionControlNetPipeline.from_pretrained(
261
  base_model_path, controlnet=controlnet, torch_dtype=torch.float16, safety_checker=None
262
  )
 
466
  control_scale,
467
  enable_auto_prompt, a_prompt, n_prompt,
468
  num_samples, image_resolution, detect_resolution,
469
+ ddim_steps, guess_mode, scale, seed, eta,
470
  enable_tile=True, refine_alignment_ratio=None, refine_image_resolution=None, condition_model=None):
471
 
472
  if condition_model is None:
 
544
  prompt_embeds = torch.cat([prompt_embeds] * num_samples, dim=0)
545
  negative_prompt_embeds = torch.cat(
546
  [negative_prompt_embeds] * num_samples, dim=0)
547
+ if enable_all_generate and self.extra_inpaint:
548
  self.pipe.safety_checker = lambda images, clip_input: (
549
  images, False)
550
  x_samples = self.pipe(
 
556
  width=W,
557
  image=[control.type(torch.float16)],
558
  controlnet_conditioning_scale=[float(control_scale)],
559
+ guidance_scale=scale,
560
  ).images
561
  else:
562
  multi_condition_image = []
 
580
  height=H,
581
  width=W,
582
  controlnet_conditioning_scale=multi_condition_scale,
583
+ guidance_scale=scale,
584
  ).images
585
  results = [x_samples[i] for i in range(num_samples)]
586
 
 
607
  width=img_tile.size[0],
608
  controlnet_conditioning_scale=1.0,
609
  alignment_ratio=refine_alignment_ratio,
610
+ guidance_scale=scale,
611
  ).images
612
  results_tile += x_samples_tile
613