Drazcat-AI commited on
Commit
214ca09
·
1 Parent(s): c4dd0da

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +14 -8
handler.py CHANGED
@@ -1,14 +1,20 @@
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)
 
 
 
 
 
 
 
 
1
  from huggingface_hub import hf_hub_download
2
+ from typing import Dict, List, Any
3
  from ultralytics import YOLO
4
  import cv2
5
  import torch
6
  import numpy as np
7
+ class EndpointHandler():
8
+ def __init__(self, path=""):
9
+ hf_hub_download(repo_id="Drazcat-AI/galletas", filename="yolov8_galletas/runs/detect/train/weights/best.pt")
 
10
 
11
+ def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
12
+
13
+ model = YOLO('/root/.cache/huggingface/hub/models--Drazcat-AI--galletas/snapshots/d960a6784ad838e30f01690ce813fb4dc7460bc0/yolov8_galletas/runs/detect/train/weights/best.pt')
14
+ results = model('https://rocketpin-ml-images.s3.amazonaws.com/smu/visits/1120/IMG_20230609_173208_902.jpg', imgsz=800)
15
+ img = cv2.imread('IMG_20230609_173208_902.jpg')
16
+ img = cv2.resize(img, (640, 800))
17
+
18
+ for result in results:
19
+ cv2.imshow("result", result)
20
+ cv2.waitKey(0)