shgao commited on
Commit
24d750d
1 Parent(s): 11a775c
Files changed (2) hide show
  1. app.py +1 -1
  2. sam2edit.py +3 -1
app.py CHANGED
@@ -2,7 +2,7 @@ import gradio as gr
2
 
3
 
4
  from sam2edit import create_demo as create_demo_edit_anything
5
- from sam2image import create_demo as create_demo_generate_anything
6
 
7
 
8
  DESCRIPTION = '# [Edit Anything](https://github.com/sail-sg/EditAnything)'
 
2
 
3
 
4
  from sam2edit import create_demo as create_demo_edit_anything
5
+ # from sam2image import create_demo as create_demo_generate_anything
6
 
7
 
8
  DESCRIPTION = '# [Edit Anything](https://github.com/sail-sg/EditAnything)'
sam2edit.py CHANGED
@@ -31,6 +31,7 @@ def create_demo():
31
  base_model_path = "stabilityai/stable-diffusion-2-inpainting"
32
  config_dict = OrderedDict([('SAM Pretrained(v0-1)', 'shgao/edit-anything-v0-1-1'),
33
  ('LAION Pretrained(v0-3)', 'shgao/edit-anything-v0-3'),
 
34
  ])
35
  def obtain_generation_model(controlnet_path):
36
  controlnet = ControlNetModel.from_pretrained(controlnet_path, torch_dtype=torch.float16)
@@ -46,6 +47,7 @@ def create_demo():
46
  # pipe.to(device)
47
  return pipe
48
  global default_controlnet_path
 
49
  default_controlnet_path = config_dict['LAION Pretrained(v0-3)']
50
  pipe = obtain_generation_model(default_controlnet_path)
51
 
@@ -127,10 +129,10 @@ def create_demo():
127
  if mask_image is None:
128
  mask_image = source_image["mask"]
129
  global default_controlnet_path
130
- global pipe
131
  print("To Use:", config_dict[condition_model], "Current:", default_controlnet_path)
132
  if default_controlnet_path!=config_dict[condition_model]:
133
  print("Change condition model to:", config_dict[condition_model])
 
134
  pipe = obtain_generation_model(config_dict[condition_model])
135
  default_controlnet_path = config_dict[condition_model]
136
 
 
31
  base_model_path = "stabilityai/stable-diffusion-2-inpainting"
32
  config_dict = OrderedDict([('SAM Pretrained(v0-1)', 'shgao/edit-anything-v0-1-1'),
33
  ('LAION Pretrained(v0-3)', 'shgao/edit-anything-v0-3'),
34
+ # ('LAION Pretrained(v0-3-1)', '../../edit/edit-anything-ckpt-v0-3'),
35
  ])
36
  def obtain_generation_model(controlnet_path):
37
  controlnet = ControlNetModel.from_pretrained(controlnet_path, torch_dtype=torch.float16)
 
47
  # pipe.to(device)
48
  return pipe
49
  global default_controlnet_path
50
+ global pipe
51
  default_controlnet_path = config_dict['LAION Pretrained(v0-3)']
52
  pipe = obtain_generation_model(default_controlnet_path)
53
 
 
129
  if mask_image is None:
130
  mask_image = source_image["mask"]
131
  global default_controlnet_path
 
132
  print("To Use:", config_dict[condition_model], "Current:", default_controlnet_path)
133
  if default_controlnet_path!=config_dict[condition_model]:
134
  print("Change condition model to:", config_dict[condition_model])
135
+ global pipe
136
  pipe = obtain_generation_model(config_dict[condition_model])
137
  default_controlnet_path = config_dict[condition_model]
138