mouseland commited on
Commit
2d8800e
·
verified ·
1 Parent(s): 26f7625

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -3
app.py CHANGED
@@ -221,6 +221,11 @@ def download_function():
221
  b2 = gr.DownloadButton("Download outline image as PNG", visible=False)
222
  return b1, b2
223
 
 
 
 
 
 
224
  with gr.Blocks(title = "Hello",
225
  css=".gradio-container {background:purple;}") as demo:
226
 
@@ -230,9 +235,10 @@ with gr.Blocks(title = "Hello",
230
  gr.HTML("""<h4 style="color:white;">You may need to refresh/login for 5 minutes of free GPU compute/day. </h4>""")
231
  gr.HTML("""<h4 style="color:white;">"pip install cellpose" for full functionality. </h4>""")
232
 
233
- input_image = gr.Image(label = "Input image", type = "filepath")
234
 
235
  with gr.Row():
 
236
  resize = gr.Number(label = 'max resize', value = 1000)
237
 
238
  with gr.Column():
@@ -255,8 +261,8 @@ with gr.Blocks(title = "Hello",
255
  sample_list.append("samples/img%0.2d.png"%j)
256
  gr.Examples(sample_list, inputs=input_image, examples_per_page=25)
257
 
258
-
259
- send_btn.click(fn=cellpose_segment, inputs=[input_image, resize], outputs=[img_outlines, img_overlay, flows, down_btn, down_btn2])
260
 
261
  #down_btn.click(download_function, None, [down_btn, down_btn2])
262
 
 
221
  b2 = gr.DownloadButton("Download outline image as PNG", visible=False)
222
  return b1, b2
223
 
224
+ def upload_file(filepath):
225
+ img = imread(filepath)
226
+
227
+ return img
228
+
229
  with gr.Blocks(title = "Hello",
230
  css=".gradio-container {background:purple;}") as demo:
231
 
 
235
  gr.HTML("""<h4 style="color:white;">You may need to refresh/login for 5 minutes of free GPU compute/day. </h4>""")
236
  gr.HTML("""<h4 style="color:white;">"pip install cellpose" for full functionality. </h4>""")
237
 
238
+ input_image = gr.Image(label = "Input image", type = "numpy")
239
 
240
  with gr.Row():
241
+ up_btn = gr.UploadButton("Upload (png, jpg, tif etc)", visible=True, file_count = "single")
242
  resize = gr.Number(label = 'max resize', value = 1000)
243
 
244
  with gr.Column():
 
261
  sample_list.append("samples/img%0.2d.png"%j)
262
  gr.Examples(sample_list, inputs=input_image, examples_per_page=25)
263
 
264
+ up_btn.upload(fn = upload_file, up_btn, input_image)
265
+ send_btn.click(fn=cellpose_segment, inputs=[up_btn, resize], outputs=[img_outlines, img_overlay, flows, down_btn, down_btn2])
266
 
267
  #down_btn.click(download_function, None, [down_btn, down_btn2])
268