File size: 814 Bytes
0e28ea3
 
 
 
 
 
 
2c597e4
0e28ea3
 
2c597e4
0e28ea3
 
 
 
 
 
 
8904ecb
0e28ea3
 
 
8904ecb
0e28ea3
 
 
8904ecb
 
a6c85c4
8904ecb
0e28ea3
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import gradio as gr
from predict import ONNXInference

PRED = []

def detect(files):
    model = ONNXInference(
        model_path="./torchFlow-ckpt.onnx",
        files=files,
        save_image=False,
        save_path="./"
    )
    res = model.run()
    img_id = res["IMG_ID"]
    pred_lab = res["PRED_LAB"],
    pred_ct = res["PRED_CT"],
    geo_tag_url =  res["GEO_TAG_URL"]
    PRED.append(pred_ct)
    return f"Predicted: {PRED}"

with gr.Blocks() as demo:
    with gr.Row():
        output=gr.File()
    with gr.Row():
        btn = gr.UploadButton(
            label="Upload Image",
            file_types=[".jpg",".jpeg"],
            file_count="multiple")
        btn.upload(fn=detect, inputs=btn, outputs=[gr.Label()], api_name="predict")
# put gr.Label() in upload(outputs=gr.Label())

demo.launch()