Download app.py from iamtejanb/objdetect: direct link, hf CLI and curl.
- Browser
- Download file 785 Bytes
-
https://huggingface.co/spaces/iamtejanb/objdetect/resolve/main/app.py
- Command line
-
hf download hf://spaces/iamtejanb/objdetect/app.py
-
curl -L -o app.py https://huggingface.co/spaces/iamtejanb/objdetect/resolve/main/app.py
785 Bytes
| import os | |
| import gradio as gr | |
| from helper import load_image_from_url, render_results_in_image | |
| from PIL import Image | |
| from transformers import pipeline | |
| def get_pipeline_prediction(pil_image): | |
| pipeline_output = od_pipe(pil_image) | |
| processed_image = render_results_in_image(pil_image, | |
| pipeline_output) | |
| return processed_image | |
| #od_pipe = pipeline("object-detection", "./models/facebook/detr-resnet-50") | |
| od_pipe = pipeline("object-detection", model = "facebook/detr-resnet-50") | |
| demo = gr.Interface( | |
| fn=get_pipeline_prediction, | |
| inputs=gr.Image(label="Input image", | |
| type="pil"), | |
| outputs=gr.Image(label="Output image with predicted instances", | |
| type="pil") | |
| ) | |
| demo.launch(share=True) |