Skip to content

Add tutorial for Indian Currency Note Detection using YOLOv5 #3455

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
75 changes: 75 additions & 0 deletions beginner_source/indian_notes_detection_tutorial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
"""
Title: Indian Currency Note Detection using YOLOv5
Author: Your Name
Description:
This tutorial demonstrates how to detect Indian currency notes using YOLOv5 and Roboflow.
It covers dataset download, training, inference, and retraining for improved accuracy.

Requirements:
- Roboflow account with access to the dataset.
- Google Colab or local environment with GPU.
- Replace 'YOUR_API_KEY_HERE' with your Roboflow API key.
"""

import os

# Step 1: Clone YOLOv5 repository and install requirements
print("Cloning YOLOv5 and installing dependencies...")
os.system("git clone https://github.com/ultralytics/yolov5")
os.chdir("yolov5")
os.system("pip install -r requirements.txt")
os.system("pip install roboflow")

# Step 2: Download Dataset from Roboflow
from roboflow import Roboflow

print("Downloading dataset from Roboflow...")
rf = Roboflow(api_key="YOUR_API_KEY_HERE") # Replace with your Roboflow API key
project = rf.workspace("omkar-patkar-fes59").project("indian-currency-notes")
version = project.version(4)
dataset = version.download("yolov5")

# Step 3: Explore dataset structure
print("\n📂 Dataset location:", dataset.location)
for root, dirs, files in os.walk(dataset.location):
print(f"📁 {root}")
for file in files[:5]:
print(" 📄", file)
break

# Step 4: Train the model (Initial training)
print("\n🧠 Training YOLOv5 model...")
os.system("""
python train.py \
--img 640 \
--batch 16 \
--epochs 30 \
--data indian-currency/notes-4/data.yaml \
--weights yolov5s.pt \
--project currency-project \
--name yolo_currency \
--cache
""")

# Step 5: Run inference on test images
print("\n🔍 Running detection on test images...")
os.system("""
python detect.py \
--weights currency-project/yolo_currency/weights/best.pt \
--img 640 \
--conf 0.25 \
--source indian-currency/notes-4/test/images
""")

# Step 6: Retrain with more epochs (optional)
print("\n📈 Retraining with 50 epochs for improved accuracy...")
os.system("""
python train.py \
--img 640 \
--batch 16 \
--epochs 50 \
--data indian-currency/notes-4/data.yaml \
--weights yolov5s.pt \
--project currency-project/yolo_currency_v2 \
--name improved_run
""")
14 changes: 14 additions & 0 deletions index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ Welcome to PyTorch Tutorials
:link: beginner/nn_tutorial.html
:tags: Getting-Started

.. customcarditem::
:header: Indian Currency Note Detection with YOLOv5
:card_description: Learn to train and run a YOLOv5 model to detect Indian currency notes using Roboflow and PyTorch.
:image: _static/img/thumbnails/cropped/indian-currency-yolo.png
:link: beginner/indian_notes_detection_tutorial.html
:tags: Image/Video,Object-Detection


.. customcarditem::
:header: Visualizing Models, Data, and Training with TensorBoard
:card_description: Learn to use TensorBoard to visualize data and model training.
Expand Down Expand Up @@ -783,6 +791,9 @@ Welcome to PyTorch Tutorials
:tags: TorchRec,Recommender





.. End of tutorial card section

.. raw:: html
Expand Down Expand Up @@ -832,6 +843,9 @@ Additional Resources
:button_link: beginner/colab.html
:button_text: Open




.. End of callout section

.. raw:: html
Expand Down
Loading