File size: 926 Bytes
7a4ff2c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!pip install ultralytics supervision huggingface_hub opencv-python

import cv2
import os
import supervision as sv
from huggingface_hub import hf_hub_download
from ultralytics import YOLO
from huggingface_hub import login

login(token=os.getenv("HF_TOKEN"))

#download the model
model_path = hf_hub_download(
    repo_id="tech4humans/yolov8s-signature-detector",
    filename="yolov8s.pt"
)

#load model
model = YOLO(model_path)

 # choose your image manually
from google.colab import files
uploaded = files.upload() 

 # gets the uploaded filename
image_path = list(uploaded.keys())[0] 
image = cv2.imread(image_path)

#inference part
results = model(image_path)
detections = sv.Detections.from_ultralytics(results[0])
box_annotator = sv.BoxAnnotator()
annotated_image = box_annotator.annotate(scene=image, detections=detections)
from google.colab.patches import cv2_imshow

# Show result image
cv2_imshow(annotated_image)