Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -132,7 +132,7 @@ def update_image(filepath, z):
|
|
| 132 |
filepath_show = norm_path(filepath_show)
|
| 133 |
print(filepath_show)
|
| 134 |
print(filepath)
|
| 135 |
-
return filepath_show, filepath, (fp0, [((5, 5, 10, 10), 'nothing')])
|
| 136 |
|
| 137 |
def update_button(filepath, z):
|
| 138 |
print('update_btn')
|
|
@@ -140,7 +140,7 @@ def update_button(filepath, z):
|
|
| 140 |
filepath_show = tif_view(filepath, z)
|
| 141 |
filepath_show = norm_path(filepath_show)
|
| 142 |
print(filepath_show)
|
| 143 |
-
return filepath_show, [filepath], (fp0, [((5, 5, 10, 10), 'nothing')])
|
| 144 |
|
| 145 |
def update_z(filepath, filepath_result, filepath_coordinates, z):
|
| 146 |
print('update_img')
|
|
@@ -164,7 +164,7 @@ def update_z(filepath, filepath_result, filepath_coordinates, z):
|
|
| 164 |
else:
|
| 165 |
display_boxes = filter_coordinates(filepath_coordinates, z)
|
| 166 |
|
| 167 |
-
return filepath_show, (filepath_result_show, display_boxes)
|
| 168 |
|
| 169 |
def detect_cells(filepath, z):
|
| 170 |
model = tf.keras.models.load_model('./model_positions', compile=False)
|
|
@@ -241,7 +241,8 @@ with gr.Blocks(title = "Hello",
|
|
| 241 |
</div>""")
|
| 242 |
gr.HTML("""<h4 style="color:white;">You may need to login/refresh for 5 minutes of free GPU compute per day (enough to process hundreds of images). </h4>""")
|
| 243 |
|
| 244 |
-
input_image = gr.Image(label = "Input", type = "filepath")
|
|
|
|
| 245 |
|
| 246 |
with gr.Row():
|
| 247 |
with gr.Column(scale=1):
|
|
@@ -271,7 +272,7 @@ with gr.Blocks(title = "Hello",
|
|
| 271 |
# sample_list.append("samples/img%0.2d.png"%j)
|
| 272 |
|
| 273 |
#gr.Examples(sample_list, fn = update_button, inputs=input_image, outputs = [input_image, up_btn, outlines, flows], examples_per_page=50, label = "Click on an example to try it")
|
| 274 |
-
input_image.upload(update_button, [input_image, depth], [input_image, up_btn, output_image])
|
| 275 |
up_btn.upload(update_image, [up_btn, depth], [input_image, up_btn, output_image])
|
| 276 |
depth.change(update_z, [up_btn, down_btn, down_btn2, depth], [input_image, output_image])
|
| 277 |
#depth.change(update_depth, [up_btn, depth], depth)
|
|
|
|
| 132 |
filepath_show = norm_path(filepath_show)
|
| 133 |
print(filepath_show)
|
| 134 |
print(filepath)
|
| 135 |
+
return (filepath_show, [((5, 5, 10, 10), 'nothing')]), filepath, (fp0, [((5, 5, 10, 10), 'nothing')])
|
| 136 |
|
| 137 |
def update_button(filepath, z):
|
| 138 |
print('update_btn')
|
|
|
|
| 140 |
filepath_show = tif_view(filepath, z)
|
| 141 |
filepath_show = norm_path(filepath_show)
|
| 142 |
print(filepath_show)
|
| 143 |
+
return (filepath_show, [((5, 5, 10, 10), 'nothing')]), [filepath], (fp0, [((5, 5, 10, 10), 'nothing')])
|
| 144 |
|
| 145 |
def update_z(filepath, filepath_result, filepath_coordinates, z):
|
| 146 |
print('update_img')
|
|
|
|
| 164 |
else:
|
| 165 |
display_boxes = filter_coordinates(filepath_coordinates, z)
|
| 166 |
|
| 167 |
+
return (filepath_show, display_boxes), (filepath_result_show, display_boxes)
|
| 168 |
|
| 169 |
def detect_cells(filepath, z):
|
| 170 |
model = tf.keras.models.load_model('./model_positions', compile=False)
|
|
|
|
| 241 |
</div>""")
|
| 242 |
gr.HTML("""<h4 style="color:white;">You may need to login/refresh for 5 minutes of free GPU compute per day (enough to process hundreds of images). </h4>""")
|
| 243 |
|
| 244 |
+
#input_image = gr.Image(label = "Input", type = "filepath")
|
| 245 |
+
input_image = gr.AnnotatedImage(label = "Input", show_legend=False, color_map = {'nothing': '#FFFF00'})
|
| 246 |
|
| 247 |
with gr.Row():
|
| 248 |
with gr.Column(scale=1):
|
|
|
|
| 272 |
# sample_list.append("samples/img%0.2d.png"%j)
|
| 273 |
|
| 274 |
#gr.Examples(sample_list, fn = update_button, inputs=input_image, outputs = [input_image, up_btn, outlines, flows], examples_per_page=50, label = "Click on an example to try it")
|
| 275 |
+
#input_image.upload(update_button, [input_image, depth], [input_image, up_btn, output_image])
|
| 276 |
up_btn.upload(update_image, [up_btn, depth], [input_image, up_btn, output_image])
|
| 277 |
depth.change(update_z, [up_btn, down_btn, down_btn2, depth], [input_image, output_image])
|
| 278 |
#depth.change(update_depth, [up_btn, depth], depth)
|