detect-it / app.py
torchFlow's picture
Update app.py
e3394c8
raw
history blame contribute delete
843 Bytes
import gradio as gr
from predict import ONNXInference
import json
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"]
result = json.dumps(res)
return result
with gr.Blocks() as demo:
gr.Markdown("# DetectIt")
with gr.Row():
image = gr.UploadButton(
label="Upload Image",
file_types=[".jpg",".jpeg"],
file_count="multiple")
btn = gr.Button("Go")
text = gr.Textbox(show_label=False, elem_id="result-textarea")
btn.click(detect, inputs=[image], outputs=[text], api_name="predict")
demo.launch()