2022-04-15 17:20:19 +08:00
|
|
|
import gradio as gr
|
|
|
|
import time
|
2022-03-01 12:35:21 +08:00
|
|
|
|
2023-06-20 04:02:03 +08:00
|
|
|
disease_values = [0.25, 0.5, 0.75]
|
|
|
|
|
2022-04-15 17:20:19 +08:00
|
|
|
def xray_model(diseases, img):
|
2023-06-20 04:02:03 +08:00
|
|
|
return [{disease: disease_values[idx] for idx,disease in enumerate(diseases)}]
|
2022-04-15 17:20:19 +08:00
|
|
|
|
|
|
|
|
|
|
|
def ct_model(diseases, img):
|
2022-05-14 13:45:44 +08:00
|
|
|
return [{disease: 0.1 for disease in diseases}]
|
2022-03-01 12:35:21 +08:00
|
|
|
|
2022-04-01 19:26:23 +08:00
|
|
|
with gr.Blocks() as demo:
|
2022-03-29 03:59:30 +08:00
|
|
|
gr.Markdown(
|
2022-04-05 06:47:51 +08:00
|
|
|
"""
|
2022-03-29 03:59:30 +08:00
|
|
|
# Detect Disease From Scan
|
|
|
|
With this model you can lorem ipsum
|
|
|
|
- ipsum 1
|
|
|
|
- ipsum 2
|
|
|
|
"""
|
2022-03-01 12:35:21 +08:00
|
|
|
)
|
2023-06-22 03:25:25 +08:00
|
|
|
gr.DuplicateButton()
|
2022-03-29 03:59:30 +08:00
|
|
|
disease = gr.CheckboxGroup(
|
2023-02-23 07:16:15 +08:00
|
|
|
info="Select the diseases you want to scan for.",
|
2022-03-25 14:03:47 +08:00
|
|
|
choices=["Covid", "Malaria", "Lung Cancer"], label="Disease to Scan For"
|
|
|
|
)
|
2023-03-07 04:52:31 +08:00
|
|
|
slider = gr.Slider(0, 100)
|
2022-03-01 12:35:21 +08:00
|
|
|
|
2022-08-30 10:51:01 +08:00
|
|
|
with gr.Tab("X-ray") as x_tab:
|
|
|
|
with gr.Row():
|
|
|
|
xray_scan = gr.Image()
|
|
|
|
xray_results = gr.JSON()
|
|
|
|
xray_run = gr.Button("Run")
|
|
|
|
xray_run.click(
|
|
|
|
xray_model,
|
|
|
|
inputs=[disease, xray_scan],
|
|
|
|
outputs=xray_results,
|
|
|
|
api_name="xray_model"
|
|
|
|
)
|
2022-03-12 08:40:23 +08:00
|
|
|
|
2022-08-30 10:51:01 +08:00
|
|
|
with gr.Tab("CT Scan"):
|
|
|
|
with gr.Row():
|
|
|
|
ct_scan = gr.Image()
|
|
|
|
ct_results = gr.JSON()
|
|
|
|
ct_run = gr.Button("Run")
|
|
|
|
ct_run.click(
|
|
|
|
ct_model,
|
|
|
|
inputs=[disease, ct_scan],
|
|
|
|
outputs=ct_results,
|
|
|
|
api_name="ct_model"
|
|
|
|
)
|
2022-03-01 12:35:21 +08:00
|
|
|
|
2023-03-07 04:52:31 +08:00
|
|
|
upload_btn = gr.Button("Upload Results", variant="primary")
|
2022-04-15 17:20:19 +08:00
|
|
|
upload_btn.click(
|
2023-06-20 04:02:03 +08:00
|
|
|
lambda ct, xr: None,
|
2022-04-15 17:20:19 +08:00
|
|
|
inputs=[ct_results, xray_results],
|
|
|
|
outputs=[],
|
|
|
|
)
|
2022-03-01 12:35:21 +08:00
|
|
|
|
2022-03-29 03:59:30 +08:00
|
|
|
if __name__ == "__main__":
|
|
|
|
demo.launch()
|