Skip to content

Commit 81c9488

Browse files
committed
Add YOLOv5 tutorial for Indian Currency Note Detection
1 parent c1cd7ab commit 81c9488

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
"""
2+
Title: Indian Currency Note Detection using YOLOv5
3+
Author: Your Name
4+
Description:
5+
This tutorial demonstrates how to detect Indian currency notes using YOLOv5 and Roboflow.
6+
It covers dataset download, training, inference, and retraining for improved accuracy.
7+
8+
Requirements:
9+
- Roboflow account with access to the dataset.
10+
- Google Colab or local environment with GPU.
11+
- Replace 'YOUR_API_KEY_HERE' with your Roboflow API key.
12+
"""
13+
14+
import os
15+
16+
# Step 1: Clone YOLOv5 repository and install requirements
17+
print("Cloning YOLOv5 and installing dependencies...")
18+
os.system("git clone https://github.com/ultralytics/yolov5")
19+
os.chdir("yolov5")
20+
os.system("pip install -r requirements.txt")
21+
os.system("pip install roboflow")
22+
23+
# Step 2: Download Dataset from Roboflow
24+
from roboflow import Roboflow
25+
26+
print("Downloading dataset from Roboflow...")
27+
rf = Roboflow(api_key="YOUR_API_KEY_HERE") # Replace with your Roboflow API key
28+
project = rf.workspace("omkar-patkar-fes59").project("indian-currency-notes")
29+
version = project.version(4)
30+
dataset = version.download("yolov5")
31+
32+
# Step 3: Explore dataset structure
33+
print("\n📂 Dataset location:", dataset.location)
34+
for root, dirs, files in os.walk(dataset.location):
35+
print(f"📁 {root}")
36+
for file in files[:5]:
37+
print(" 📄", file)
38+
break
39+
40+
# Step 4: Train the model (Initial training)
41+
print("\n🧠 Training YOLOv5 model...")
42+
os.system("""
43+
python train.py \
44+
--img 640 \
45+
--batch 16 \
46+
--epochs 30 \
47+
--data indian-currency/notes-4/data.yaml \
48+
--weights yolov5s.pt \
49+
--project currency-project \
50+
--name yolo_currency \
51+
--cache
52+
""")
53+
54+
# Step 5: Run inference on test images
55+
print("\n🔍 Running detection on test images...")
56+
os.system("""
57+
python detect.py \
58+
--weights currency-project/yolo_currency/weights/best.pt \
59+
--img 640 \
60+
--conf 0.25 \
61+
--source indian-currency/notes-4/test/images
62+
""")
63+
64+
# Step 6: Retrain with more epochs (optional)
65+
print("\n📈 Retraining with 50 epochs for improved accuracy...")
66+
os.system("""
67+
python train.py \
68+
--img 640 \
69+
--batch 16 \
70+
--epochs 50 \
71+
--data indian-currency/notes-4/data.yaml \
72+
--weights yolov5s.pt \
73+
--project currency-project/yolo_currency_v2 \
74+
--name improved_run
75+
""")

0 commit comments

Comments
 (0)