Commit
·
c4dd0da
1
Parent(s):
d960a67
Create handler.py
Browse files- handler.py +14 -0
handler.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from huggingface_hub import hf_hub_download
|
| 2 |
+
hf_hub_download(repo_id="Drazcat-AI/galletas", filename="yolov8_galletas/runs/detect/train/weights/best.pt")
|
| 3 |
+
from ultralytics import YOLO
|
| 4 |
+
import cv2
|
| 5 |
+
import torch
|
| 6 |
+
import numpy as np
|
| 7 |
+
model = YOLO('/root/.cache/huggingface/hub/models--Drazcat-AI--galletas/snapshots/d960a6784ad838e30f01690ce813fb4dc7460bc0/yolov8_galletas/runs/detect/train/weights/best.pt')
|
| 8 |
+
results = model('https://rocketpin-ml-images.s3.amazonaws.com/smu/visits/1120/IMG_20230609_173208_902.jpg', imgsz=800)
|
| 9 |
+
img = cv2.imread('IMG_20230609_173208_902.jpg')
|
| 10 |
+
img = cv2.resize(img, (640, 800))
|
| 11 |
+
|
| 12 |
+
for result in results:
|
| 13 |
+
cv2.imshow("result", result)
|
| 14 |
+
cv2.waitKey(0)
|