Spaces:
Sleeping
Sleeping
Download app.py from lamba66/Image_Segmentation: direct link, hf CLI and curl.
- Browser
- Download file 645 Bytes
-
https://huggingface.co/spaces/lamba66/Image_Segmentation/resolve/main/app.py
- Command line
-
hf download hf://spaces/lamba66/Image_Segmentation/app.py
-
curl -L -o app.py https://huggingface.co/spaces/lamba66/Image_Segmentation/resolve/main/app.py
645 Bytes
| import gradio as gr | |
| from ultralytics import YOLO | |
| import cv2 | |
| import numpy as np | |
| # charger le modèle | |
| model = YOLO("yolov8n-seg.pt") | |
| # Fonction pour la détection sur image | |
| def detect_objects_image(img): | |
| results = model(img) # Détection | |
| annotated_frame = results[0].plot() # Annoter les résultats | |
| return annotated_frame | |
| demo = gr.Blocks() | |
| #Interface Gradio | |
| image_input = gr.Image(type="numpy", label="Image à analyser") | |
| image_output = gr.Image(type="numpy", label="Image annotée") | |
| interface = gr.Interface(fn=detect_objects_image, inputs=image_input, outputs=image_output, title="Détection sur Image") | |
| interface.launch() |