forked from replayce/back_python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjelly_image.py
More file actions
24 lines (18 loc) · 721 Bytes
/
jelly_image.py
File metadata and controls
24 lines (18 loc) · 721 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import os
from ultralytics import YOLO
def predict_jelly_image(image_path):
model_path = os.path.join(os.path.dirname(__file__), "models", "image_best.pt")
model = YOLO(model_path)
results = model.predict(source=image_path, save=False)
predictions = []
for result in results:
for conf, cls in zip(result.boxes.conf, result.boxes.cls):
class_name = result.names[int(cls)]
confidence_percent = conf.item() * 100
predictions.append({
'class': class_name,
'confidence': confidence_percent
})
return predictions
if __name__ == '__main__':
print(predict_jelly_image('노무라입깃.jpg'))