Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -9,17 +9,19 @@ model = YOLO('Dental_model.pt') # Replace 'yolov8n.pt' with your model file if
|
|
9 |
pic_files=glob.glob('*.jpg')
|
10 |
names=model.model.names
|
11 |
def detect_objects(image):
|
12 |
-
image1=image.copy()
|
13 |
results = model.predict(image)
|
14 |
-
|
15 |
-
|
16 |
-
boxes=results[0].boxes.xyxy.cpu()
|
17 |
annotator = Annotator(image, line_width=3)
|
18 |
-
annotator1=Annotator(image1, line_width=3)
|
19 |
-
|
|
|
20 |
annotator.box_label(box, label=names[int(cls)], color=colors(int(cls)))
|
21 |
annotator1.box_label(box, label=None, color=colors(int(cls)))
|
22 |
-
|
|
|
|
|
23 |
|
24 |
# Gradio Interface
|
25 |
title = "YOLOv8 Object Detection"
|
|
|
9 |
pic_files=glob.glob('*.jpg')
|
10 |
names=model.model.names
|
11 |
def detect_objects(image):
|
12 |
+
image1 = image.copy()
|
13 |
results = model.predict(image)
|
14 |
+
classes = results[0].boxes.cls.cpu().tolist()
|
15 |
+
boxes = results[0].boxes.xyxy.cpu()
|
|
|
16 |
annotator = Annotator(image, line_width=3)
|
17 |
+
annotator1 = Annotator(image1, line_width=3)
|
18 |
+
|
19 |
+
for box, cls in zip(boxes, classes):
|
20 |
annotator.box_label(box, label=names[int(cls)], color=colors(int(cls)))
|
21 |
annotator1.box_label(box, label=None, color=colors(int(cls)))
|
22 |
+
|
23 |
+
return Image.fromarray(annotator.result()), Image.fromarray(annotator1.result())
|
24 |
+
|
25 |
|
26 |
# Gradio Interface
|
27 |
title = "YOLOv8 Object Detection"
|