mouseland commited on
Commit
5261ab2
·
verified ·
1 Parent(s): fe58ba1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -10
app.py CHANGED
@@ -242,15 +242,15 @@ def download_function():
242
 
243
  def upload_file(filepath):
244
  img = imread(filepath)
245
- img = normalize99(img)
246
- img = np.clip(img, 0, 1)
247
 
248
- filegui = os.path.splitext(filepath)[0]+"_gui.png"
249
- imsave(filegui, img)
250
 
251
- b1 = gr.DownloadButton("Download masks as TIFF", visible=False)
252
- b2 = gr.DownloadButton("Download outline image as PNG", visible=False)
253
- return filegui, filepath, b1, b2
254
 
255
 
256
  def update_image(filepath):
@@ -278,12 +278,12 @@ with gr.Blocks(title = "Hello",
278
 
279
  with gr.Row():
280
  with gr.Column(scale=1):
 
281
  resize = gr.Number(label = 'max resize', value = 1000)
282
 
283
  #gr.HTML("""<h4 style="color:white;"> Note2: Only the first image of a tif will display the segmentations, but you can download segmentations for all planes. </h4>""")
284
 
285
- #filepath = gr.UploadButton("Upload (png, jpg, tif etc)", visible=True, file_count = "single")
286
-
287
 
288
  with gr.Column(scale=1):
289
  send_btn = gr.Button("Run Cellpose-SAM")
@@ -306,7 +306,7 @@ with gr.Blocks(title = "Hello",
306
  gr.Examples(sample_list, inputs=input_image, examples_per_page=25, label = "Click on an example to try it")
307
 
308
  #input_image.change(update_image, input_image, [input_image, filepath])
309
- #up_btn.upload(upload_file, up_btn, [input_image, up_btn, down_btn, down_btn2])
310
  send_btn.click(cellpose_segment, [input_image, resize], [img_outlines, flows, down_btn, down_btn2])
311
 
312
  #down_btn.click(download_function, None, [down_btn, down_btn2])
 
242
 
243
  def upload_file(filepath):
244
  img = imread(filepath)
245
+ #img = normalize99(img)
246
+ #img = np.clip(img, 0, 1)
247
 
248
+ #filegui = os.path.splitext(filepath)[0]+"_gui.png"
249
+ #imsave(filegui, img)
250
 
251
+ #b1 = gr.DownloadButton("Download masks as TIFF", visible=False)
252
+ #b2 = gr.DownloadButton("Download outline image as PNG", visible=False)
253
+ return filepath #, b1, b2
254
 
255
 
256
  def update_image(filepath):
 
278
 
279
  with gr.Row():
280
  with gr.Column(scale=1):
281
+ up_btn = gr.UploadButton("Upload (png, jpg, tif etc)", visible=True, file_count = "single")
282
  resize = gr.Number(label = 'max resize', value = 1000)
283
 
284
  #gr.HTML("""<h4 style="color:white;"> Note2: Only the first image of a tif will display the segmentations, but you can download segmentations for all planes. </h4>""")
285
 
286
+
 
287
 
288
  with gr.Column(scale=1):
289
  send_btn = gr.Button("Run Cellpose-SAM")
 
306
  gr.Examples(sample_list, inputs=input_image, examples_per_page=25, label = "Click on an example to try it")
307
 
308
  #input_image.change(update_image, input_image, [input_image, filepath])
309
+ up_btn.upload(upload_file, up_btn, [input_image])
310
  send_btn.click(cellpose_segment, [input_image, resize], [img_outlines, flows, down_btn, down_btn2])
311
 
312
  #down_btn.click(download_function, None, [down_btn, down_btn2])