lsb commited on
Commit
be54e00
1 Parent(s): 2f284ac

no old size, yes inference steps, warm up on two sizes

Browse files
Files changed (1) hide show
  1. app.py +11 -6
app.py CHANGED
@@ -66,7 +66,6 @@ def get_seg_mask(img):
66
 
67
  def app(img, prompt, num_inference_steps, seed, inpaint_size):
68
  start_time = datetime.now().timestamp()
69
- old_size = Image.fromarray(img).size
70
  img = np.array(Image.fromarray(img).resize(seg_working_size))
71
  mask = get_seg_mask(img)
72
  # mask.save("mask.jpg")
@@ -88,15 +87,21 @@ def app(img, prompt, num_inference_steps, seed, inpaint_size):
88
  # replace spaces with newlines after many words to line break prompt
89
  prompt = " ".join([prompt.split(" ")[i] if (i+1) % 5 else prompt.split(" ")[i] + "\n" for i in range(len(prompt.split(" ")))])
90
 
91
- draw.text((10, 50), f"Old size: {old_size}\nTotal duration: {int(1000 * (end_time - start_time))}ms\nSegmentation {int(1000 * (mask_time - start_time))}ms / inpainting {int(1000 * (end_time - mask_time))} \n<{prompt}>", fill=(0, 255, 0))
 
 
 
 
 
92
  #overlay_img.save("overlay_with_text.jpg")
93
  return overlay_img
94
 
95
  # warmup, for compiling and then for timing
96
 
97
- for i in range(2):
98
- for j in tqdm(range(3 ** i)):
99
- app(np.array(Image.fromarray(np.zeros((1024,1024,3), dtype=np.uint8))), default_inpainting_prompt, 4, 42, 512).save("zeros_inpainting_oneshot.jpg")
 
100
 
101
  #ideally:
102
  #iface = gr.Interface(app, gr.Image(sources=["webcam"], streaming=True), "image", live=True)
@@ -108,4 +113,4 @@ iface = gr.Interface(app, [
108
  gr.Number(value=512, maximum=seg_model_img_size,)
109
  ],
110
  "image")
111
- iface.launch()
 
66
 
67
  def app(img, prompt, num_inference_steps, seed, inpaint_size):
68
  start_time = datetime.now().timestamp()
 
69
  img = np.array(Image.fromarray(img).resize(seg_working_size))
70
  mask = get_seg_mask(img)
71
  # mask.save("mask.jpg")
 
87
  # replace spaces with newlines after many words to line break prompt
88
  prompt = " ".join([prompt.split(" ")[i] if (i+1) % 5 else prompt.split(" ")[i] + "\n" for i in range(len(prompt.split(" ")))])
89
 
90
+ draw.text((10, 50), "\n".join([
91
+ f"Total duration: {int(1000 * (end_time - start_time))}ms",
92
+ f"Inference steps: {num_inference_steps}",
93
+ f"Segmentation {int(1000 * (mask_time - start_time))}ms / inpainting {int(1000 * (end_time - mask_time))}",
94
+ f"<{prompt}>"
95
+ ]), fill=(0, 255, 0))
96
  #overlay_img.save("overlay_with_text.jpg")
97
  return overlay_img
98
 
99
  # warmup, for compiling and then for timing
100
 
101
+ for size in [384,512]:
102
+ for i in range(2):
103
+ for j in tqdm(range(3 ** i)):
104
+ app(np.array(Image.fromarray(np.zeros((1024,1024,3), dtype=np.uint8))), default_inpainting_prompt, 4, 42, size).save("zeros_inpainting_oneshot.jpg")
105
 
106
  #ideally:
107
  #iface = gr.Interface(app, gr.Image(sources=["webcam"], streaming=True), "image", live=True)
 
113
  gr.Number(value=512, maximum=seg_model_img_size,)
114
  ],
115
  "image")
116
+ iface.launch(share=True)