Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -27,11 +27,34 @@ if report_interface.prime_model() is False:
|
|
| 27 |
else:
|
| 28 |
print("Model priming successful.")
|
| 29 |
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
gr.Markdown("## Radiology Report Assistant")
|
| 32 |
gr.Markdown(report_interface.help_message)
|
| 33 |
|
| 34 |
-
running = gr.components.Variable(True)
|
| 35 |
report_textbox = gr.TextArea(label="Report", lines=20, max_lines=50)
|
| 36 |
check_btn = gr.Button(
|
| 37 |
value="Check Report",
|
|
@@ -45,24 +68,7 @@ with gr.Blocks(theme="finlaymacklon/smooth_slate") as demo:
|
|
| 45 |
results_textbox = gr.TextArea(label="Results", lines=20, max_lines=50)
|
| 46 |
clear_btn.add([results_textbox, report_textbox])
|
| 47 |
|
| 48 |
-
def check_report(report):
|
| 49 |
-
if running.value is True:
|
| 50 |
-
results = report_interface.process_input(report)
|
| 51 |
-
if results == "quit":
|
| 52 |
-
quit_fn()
|
| 53 |
-
elif results == "help":
|
| 54 |
-
return report_interface.help_message
|
| 55 |
-
elif results == "exception":
|
| 56 |
-
return "An exception occurred. Please try again."
|
| 57 |
-
else:
|
| 58 |
-
return results
|
| 59 |
-
else:
|
| 60 |
-
return "Model has been stopped."
|
| 61 |
-
|
| 62 |
-
def quit_fn():
|
| 63 |
-
return "Model has been stopped.", False
|
| 64 |
-
|
| 65 |
check_btn.click(fn=check_report, inputs=[report_textbox], outputs=[results_textbox])
|
| 66 |
-
quit_btn.click(fn=quit_fn, outputs=[results_textbox
|
| 67 |
|
| 68 |
demo.launch(auth=(user, passwd))
|
|
|
|
| 27 |
else:
|
| 28 |
print("Model priming successful.")
|
| 29 |
|
| 30 |
+
running = False
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
def check_report(report):
|
| 34 |
+
if running:
|
| 35 |
+
results = report_interface.process_input(report)
|
| 36 |
+
if results == "quit":
|
| 37 |
+
quit_fn()
|
| 38 |
+
elif results == "help":
|
| 39 |
+
return report_interface.help_message
|
| 40 |
+
elif results == "exception":
|
| 41 |
+
return "An exception occurred. Please try again."
|
| 42 |
+
else:
|
| 43 |
+
return results
|
| 44 |
+
else:
|
| 45 |
+
return "Model has been stopped."
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
def quit_fn():
|
| 49 |
+
global running
|
| 50 |
+
running = False
|
| 51 |
+
return "Model has been stopped."
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
with gr.Blocks(theme="soft") as demo:
|
| 55 |
gr.Markdown("## Radiology Report Assistant")
|
| 56 |
gr.Markdown(report_interface.help_message)
|
| 57 |
|
|
|
|
| 58 |
report_textbox = gr.TextArea(label="Report", lines=20, max_lines=50)
|
| 59 |
check_btn = gr.Button(
|
| 60 |
value="Check Report",
|
|
|
|
| 68 |
results_textbox = gr.TextArea(label="Results", lines=20, max_lines=50)
|
| 69 |
clear_btn.add([results_textbox, report_textbox])
|
| 70 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
check_btn.click(fn=check_report, inputs=[report_textbox], outputs=[results_textbox])
|
| 72 |
+
quit_btn.click(fn=quit_fn, outputs=[results_textbox])
|
| 73 |
|
| 74 |
demo.launch(auth=(user, passwd))
|