syedatasneem1
commited on
Commit
•
b2ed2c4
1
Parent(s):
d0c2079
Upload app.py
Browse files
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from ultralytics import YOLO
|
3 |
+
from PIL import Image
|
4 |
+
|
5 |
+
det_model = YOLO("yolov8n.pt")
|
6 |
+
|
7 |
+
def detect_objects(image):
|
8 |
+
results = det_model(image)
|
9 |
+
det_img = results[0].plot()
|
10 |
+
return det_img
|
11 |
+
|
12 |
+
|
13 |
+
iface = gr.Interface(
|
14 |
+
detect_objects,
|
15 |
+
inputs=gr.Image(type="pil"),
|
16 |
+
outputs=gr.Image(type="pil"),
|
17 |
+
title="YOLOv8 Object Detection",
|
18 |
+
description="Upload an image to detect objects and see them boxed",
|
19 |
+
examples=['./image_1.jpg', './image_2.jpg', './image_3.jpg']
|
20 |
+
)
|
21 |
+
|
22 |
+
iface.launch()
|