kadirnar commited on
Commit
a99d343
1 Parent(s): fb29593

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +27 -0
  2. requirements.txt +2 -0
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from ultralytics import YOLOv10
3
+ import supervision as sv
4
+
5
+ MODEL_PATH = 'yolov10n.pt'
6
+ model = YOLOv10(MODEL_PATH)
7
+ box_annotator = sv.BoxAnnotator()
8
+
9
+ def detect(image):
10
+ results = model(source=image, conf=0.25, verbose=False)[0]
11
+ detections = sv.Detections.from_ultralytics(results)
12
+
13
+ labels = [
14
+ f"{model.model.names[class_id]} {confidence:.2f}"
15
+ for class_id, confidence in zip(detections.class_id, detections.confidence)
16
+ ]
17
+ annotated_image = box_annotator.annotate(image, detections=detections, labels=labels)
18
+
19
+ return annotated_image
20
+
21
+ gr.Interface(
22
+ fn=detect,
23
+ inputs=gr.inputs.Image(type="numpy"),
24
+ outputs=gr.outputs.Image(type="numpy", label="Annotated Image"),
25
+ title='YOLOv10 Object Detection',
26
+ description='Detect objects in images using the YOLOv10 model'
27
+ ).launch()
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ supervision
2
+ git+https://github.com/THU-MIG/yolov10.git