lsb commited on
Commit
5079795
1 Parent(s): f5b5d99
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -34,7 +34,8 @@ inpainting_pipeline = StableDiffusionInpaintPipeline.from_pretrained(
34
  #inpainting_pipeline.load_lora_weights("latent-consistency/lcm-lora-sdv1-5")
35
  #inpainting_pipeline.fuse_lora()
36
 
37
- working_size = (seg_model_img_size, seg_model_img_size)
 
38
 
39
  default_inpainting_prompt = "award-winning photo of a leafy pedestrian mall full of people, with multiracial genderqueer joggers and bicyclists and wheelchair users talking and laughing"
40
 
@@ -60,15 +61,15 @@ def get_seg_mask(img):
60
  def app(img, prompt):
61
  start_time = datetime.now().timestamp()
62
  old_size = Image.fromarray(img).size
63
- img = np.array(Image.fromarray(img).resize(working_size))
64
  mask = get_seg_mask(img)
65
- mask.save("mask.jpg")
66
  mask_time = datetime.now().timestamp()
67
  #print(prompt.__class__, img.__class__, mask.__class__, img.shape, mask.shape, mask.dtype, img.dtype)
68
  overlay_img = inpainting_pipeline(
69
  prompt=prompt,
70
- image=Image.fromarray(img),
71
- mask_image=(mask),
72
  strength=0.95,
73
  num_inference_steps=12,
74
  ).images[0]
 
34
  #inpainting_pipeline.load_lora_weights("latent-consistency/lcm-lora-sdv1-5")
35
  #inpainting_pipeline.fuse_lora()
36
 
37
+ seg_working_size = (seg_model_img_size, seg_model_img_size)
38
+ repaint_working_size = (512, 512)
39
 
40
  default_inpainting_prompt = "award-winning photo of a leafy pedestrian mall full of people, with multiracial genderqueer joggers and bicyclists and wheelchair users talking and laughing"
41
 
 
61
  def app(img, prompt):
62
  start_time = datetime.now().timestamp()
63
  old_size = Image.fromarray(img).size
64
+ img = np.array(Image.fromarray(img).resize(seg_working_size))
65
  mask = get_seg_mask(img)
66
+ # mask.save("mask.jpg")
67
  mask_time = datetime.now().timestamp()
68
  #print(prompt.__class__, img.__class__, mask.__class__, img.shape, mask.shape, mask.dtype, img.dtype)
69
  overlay_img = inpainting_pipeline(
70
  prompt=prompt,
71
+ image=Image.fromarray(img).resize(repaint_working_size),
72
+ mask_image=(mask).resize(repaint_working_size),
73
  strength=0.95,
74
  num_inference_steps=12,
75
  ).images[0]