mirror of
https://github.com/gradio-app/gradio.git
synced 2025-03-01 11:45:36 +08:00
* add theme + theme atoms * audio * buttons * chatbot * forms * start file * complete file * fixup workbench * gallery * highlighted text * label * json * upload * 3d model * atoms * chart * md + html * image * plot + build * table * tabs * tooltip * upload * tweaks * tweaks + more tooling * tweaks to padding/ lineheight * app components _ start api docs * format, more api docs * finish api docs * interpretation * todos * tweaks + cleanup * tweaks + cleanup * revert range tweaks * fix notebooks * fix test * remove tw * cleanup + login * fix gitignore * fix types * run css script * fix progress + tweaks * update demos * add css build to static check workflow * tweak ci * fix tests * tweak markdown * tweak chatbot + file * fix tabs * tweak tabs * cleanup * fix api docs * fix example gallery * add gradient to toast * fix min height for interfaces * revert tab changes * update notebooks * changes * changes * change * changes * changes * changes * changes * changes * changes * changes * changes * change * changes * changes * changes * changes * changes * changes * changes * fix * changes * changes * changes * changes * changes * changes * undo radius * undo radius * changes * changes * changes * changes * changes * changes * changes * changes * changes * changes * changes * changes * changes * changes * changes * changes * changes * changes * changes * changes * changes * changes * change * undo * Add absolute imports * mock theme in tests * clean * changes * changes --------- Co-authored-by: pngwn <hello@pngwn.io> Co-authored-by: freddyaboulton <alfonsoboulton@gmail.com> Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
62 lines
1.5 KiB
Python
62 lines
1.5 KiB
Python
import gradio as gr
|
|
import random
|
|
import time
|
|
|
|
def xray_model(diseases, img):
|
|
time.sleep(4)
|
|
return [{disease: random.random() for disease in diseases}]
|
|
|
|
|
|
def ct_model(diseases, img):
|
|
time.sleep(3)
|
|
return [{disease: 0.1 for disease in diseases}]
|
|
|
|
with gr.Blocks() as demo:
|
|
gr.Markdown(
|
|
"""
|
|
# Detect Disease From Scan
|
|
With this model you can lorem ipsum
|
|
- ipsum 1
|
|
- ipsum 2
|
|
"""
|
|
)
|
|
disease = gr.CheckboxGroup(
|
|
info="Select the diseases you want to scan for.",
|
|
choices=["Covid", "Malaria", "Lung Cancer"], label="Disease to Scan For"
|
|
)
|
|
slider = gr.Slider(0, 100)
|
|
|
|
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"
|
|
)
|
|
|
|
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"
|
|
)
|
|
|
|
upload_btn = gr.Button("Upload Results", variant="primary")
|
|
upload_btn.click(
|
|
lambda ct, xr: time.sleep(5),
|
|
inputs=[ct_results, xray_results],
|
|
outputs=[],
|
|
)
|
|
|
|
if __name__ == "__main__":
|
|
demo.launch()
|