Update app.py
Browse files
app.py
CHANGED
|
@@ -278,23 +278,73 @@ def create_interface():
|
|
| 278 |
- Use Zoom In/Out buttons or Reset View to adjust zoom level
|
| 279 |
""")
|
| 280 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 281 |
# Event handlers
|
| 282 |
-
file_input.change(
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 287 |
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
|
|
|
| 291 |
|
| 292 |
-
key_press.change(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 293 |
|
| 294 |
-
blank_btn.click(
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 298 |
|
| 299 |
js = """
|
| 300 |
<script>
|
|
@@ -312,8 +362,4 @@ def create_interface():
|
|
| 312 |
"""
|
| 313 |
gr.HTML(js)
|
| 314 |
|
| 315 |
-
return interface
|
| 316 |
-
|
| 317 |
-
if __name__ == "__main__":
|
| 318 |
-
interface = create_interface()
|
| 319 |
-
interface.launch()
|
|
|
|
| 278 |
- Use Zoom In/Out buttons or Reset View to adjust zoom level
|
| 279 |
""")
|
| 280 |
|
| 281 |
+
def update_diameter(x):
|
| 282 |
+
analyzer.circle_diameter = x
|
| 283 |
+
return f"Diameter set to {x} pixels"
|
| 284 |
+
|
| 285 |
# Event handlers
|
| 286 |
+
file_input.change(
|
| 287 |
+
fn=analyzer.load_dicom,
|
| 288 |
+
inputs=file_input,
|
| 289 |
+
outputs=[image_display, results_display]
|
| 290 |
+
)
|
| 291 |
+
|
| 292 |
+
image_display.select(
|
| 293 |
+
fn=analyzer.analyze_roi,
|
| 294 |
+
outputs=[image_display, results_display]
|
| 295 |
+
)
|
| 296 |
+
|
| 297 |
+
diameter_slider.change(
|
| 298 |
+
fn=update_diameter,
|
| 299 |
+
inputs=diameter_slider,
|
| 300 |
+
outputs=gr.Textbox(label="Status")
|
| 301 |
+
)
|
| 302 |
+
|
| 303 |
+
zoom_in_btn.click(
|
| 304 |
+
fn=analyzer.zoom_in,
|
| 305 |
+
inputs=image_display,
|
| 306 |
+
outputs=image_display
|
| 307 |
+
)
|
| 308 |
+
|
| 309 |
+
zoom_out_btn.click(
|
| 310 |
+
fn=analyzer.zoom_out,
|
| 311 |
+
inputs=image_display,
|
| 312 |
+
outputs=image_display
|
| 313 |
+
)
|
| 314 |
|
| 315 |
+
reset_btn.click(
|
| 316 |
+
fn=analyzer.reset_view,
|
| 317 |
+
outputs=image_display
|
| 318 |
+
)
|
| 319 |
|
| 320 |
+
key_press.change(
|
| 321 |
+
fn=analyzer.handle_keyboard,
|
| 322 |
+
inputs=key_press,
|
| 323 |
+
outputs=image_display
|
| 324 |
+
)
|
| 325 |
|
| 326 |
+
blank_btn.click(
|
| 327 |
+
fn=analyzer.add_blank_row,
|
| 328 |
+
inputs=image_display,
|
| 329 |
+
outputs=[image_display, results_display]
|
| 330 |
+
)
|
| 331 |
+
|
| 332 |
+
zero_btn.click(
|
| 333 |
+
fn=analyzer.add_zero_row,
|
| 334 |
+
inputs=image_display,
|
| 335 |
+
outputs=[image_display, results_display]
|
| 336 |
+
)
|
| 337 |
+
|
| 338 |
+
undo_btn.click(
|
| 339 |
+
fn=analyzer.undo_last,
|
| 340 |
+
inputs=image_display,
|
| 341 |
+
outputs=[image_display, results_display]
|
| 342 |
+
)
|
| 343 |
+
|
| 344 |
+
save_btn.click(
|
| 345 |
+
fn=analyzer.save_results,
|
| 346 |
+
outputs=[file_output, results_display]
|
| 347 |
+
)
|
| 348 |
|
| 349 |
js = """
|
| 350 |
<script>
|
|
|
|
| 362 |
"""
|
| 363 |
gr.HTML(js)
|
| 364 |
|
| 365 |
+
return interface
|
|
|
|
|
|
|
|
|
|
|
|