đ Rock Paper Scissors Object Detection Model
This YOLO v10 small model, created by FRC Team 578, is designed for educational purposes to illustrate how an object detection model works.
đ Quick Start
To use this model, you need to install the necessary libraries and download the model weights. Here are the steps:
pip install ultralytics
pip install huggingface_hub
⨠Features
- Educational Purpose: This model is trained for educational purposes, helping students understand how an object detection model works.
- YOLO v10: It is based on the YOLO v10 architecture, which is known for its efficiency in object detection.
đĻ Installation
You can install the required libraries using pip
:
pip install ultralytics
pip install huggingface_hub
đģ Usage Examples
Basic Usage
from ultralytics import YOLO
from huggingface_hub import hf_hub_download
from matplotlib import pyplot as plt
model_path = hf_hub_download(
local_dir=".",
repo_id="fairportrobotics/rock-paper-scissors",
filename="model.pt"
)
model = YOLO(model_path)
sample_path = hf_hub_download(
local_dir=".",
repo_id="fairportrobotics/rock-paper-scissors",
filename="sample.jpg"
)
res = model.predict(
source=sample_path,
project='.',
name='detected',
exist_ok=True,
save=True,
show=False,
show_labels=True,
show_conf=True,
conf=0.5
)
plt.figure(figsize=(15,10))
plt.imshow(plt.imread('detected/sample.jpg'))
plt.show()
Advanced Usage
Use the model with your webcam:
from ultralytics import YOLO
import cv2
import math
from huggingface_hub import hf_hub_download
cap = cv2.VideoCapture(0)
cap.set(3, 640)
cap.set(4, 480)
model_path = hf_hub_download(
local_dir=".",
repo_id="fairportrobotics/rock-paper-scissors",
filename="model.pt"
)
model = YOLO(model_path)
classNames = ["rock", "paper", "scissors"]
while True:
success, img = cap.read()
results = model(img, stream=True)
for r in results:
boxes = r.boxes
for box in boxes:
x1, y1, x2, y2 = box.xyxy[0]
x1, y1, x2, y2 = int(x1), int(y1), int(x2), int(y2)
cv2.rectangle(img, (x1, y1), (x2, y2), (255, 0, 255), 3)
confidence = math.ceil((box.conf[0]*100))/100
cls = int(box.cls[0])
org = [x1, y1]
font = cv2.FONT_HERSHEY_SIMPLEX
fontScale = 1
color = (255, 0, 0)
thickness = 2
cv2.putText(img, classNames[cls] + " " + str(round(confidence,2)), org, font, fontScale, color, thickness)
cv2.imshow('Webcam', img)
if cv2.waitKey(1) == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
đ Documentation
Training Data
The model was trained on 100 images found online, and no image augmentation was performed.
Metrics
Property |
Details |
Model Type |
YOLO v10 small model |
Training Data |
100 images found online, no augmentation |
Class |
Images |
Instances |
Box |
R |
mAP50 |
mAP50-95 |
all |
100 |
260 |
0.917 |
0.795 |
0.925 |
0.735 |
rock |
69 |
84 |
0.875 |
0.835 |
0.924 |
0.728 |
paper |
56 |
65 |
0.899 |
0.815 |
0.909 |
0.721 |
scissors |
88 |
111 |
0.976 |
0.736 |
0.943 |
0.755 |
đ License
This project is licensed under the GPL license.