Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -132,14 +132,25 @@ def update_button(filepath, z):
|
|
| 132 |
print(filepath_show)
|
| 133 |
return filepath_show, [filepath], fp0, fp0
|
| 134 |
|
| 135 |
-
def detect_cells(filepath):
|
| 136 |
model = tf.keras.models.load_model('/model_positions', compile=False)
|
| 137 |
|
| 138 |
img = tiff.imread(filepath)
|
| 139 |
img = img/np.max(img)
|
| 140 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 141 |
|
| 142 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 143 |
|
| 144 |
with gr.Blocks(title = "Hello",
|
| 145 |
css=".gradio-container {background:purple;}") as demo:
|
|
@@ -190,7 +201,7 @@ with gr.Blocks(title = "Hello",
|
|
| 190 |
#depth.change(update_depth, [up_btn, depth], depth)
|
| 191 |
|
| 192 |
|
| 193 |
-
send_btn.click(detect_cells, [up_btn], [output_image1, output_image2])# flows, down_btn, down_btn2])
|
| 194 |
|
| 195 |
#down_btn.click(download_function, None, [down_btn, down_btn2])
|
| 196 |
|
|
|
|
| 132 |
print(filepath_show)
|
| 133 |
return filepath_show, [filepath], fp0, fp0
|
| 134 |
|
| 135 |
+
def detect_cells(filepath, z):
|
| 136 |
model = tf.keras.models.load_model('/model_positions', compile=False)
|
| 137 |
|
| 138 |
img = tiff.imread(filepath)
|
| 139 |
img = img/np.max(img)
|
| 140 |
|
| 141 |
+
tensor = tf.convert_to_tensor(img)
|
| 142 |
+
|
| 143 |
+
result = model(tensor)
|
| 144 |
+
print(filepath)
|
| 145 |
+
fpath, fext = os.path.splitext(filepath)
|
| 146 |
+
|
| 147 |
+
filepath_result = fpath+'result'+'.tiff'
|
| 148 |
|
| 149 |
+
tiff.imwrite(filepath_result, result)
|
| 150 |
+
|
| 151 |
+
filepath_result_show = tif_view(filepath_result, z)
|
| 152 |
+
|
| 153 |
+
return filepath_result, fp1, fp1
|
| 154 |
|
| 155 |
with gr.Blocks(title = "Hello",
|
| 156 |
css=".gradio-container {background:purple;}") as demo:
|
|
|
|
| 201 |
#depth.change(update_depth, [up_btn, depth], depth)
|
| 202 |
|
| 203 |
|
| 204 |
+
send_btn.click(detect_cells, [up_btn], [down_btn, output_image1, output_image2])# flows, down_btn, down_btn2])
|
| 205 |
|
| 206 |
#down_btn.click(download_function, None, [down_btn, down_btn2])
|
| 207 |
|