Download app.py from torchFlow/detect-it: direct link, hf CLI and curl.
- Browser
- Download file 843 Bytes
-
https://huggingface.co/spaces/torchFlow/detect-it/resolve/main/app.py
- Command line
-
hf download hf://spaces/torchFlow/detect-it/app.py
-
curl -L -o app.py https://huggingface.co/spaces/torchFlow/detect-it/resolve/main/app.py
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() |