A deep learning project that classifies yoga poses using Convolutional Neural Networks (CNN). The model can identify and classify 5 different yoga poses: Downdog, Goddess, Plank, Tree, and Warrior2.
This project uses TensorFlow and Keras to build a CNN model that can accurately classify yoga poses from images. The model achieves high accuracy in distinguishing between the 5 different yoga poses included in the dataset.
- Downdog - Downward-Facing Dog pose
- Goddess - Goddess pose
- Plank - Plank pose
- Tree - Tree pose
- Warrior2 - Warrior II pose
- CNN-based image classification
- Data augmentation for better generalization
- Model training with validation
- Real-time pose prediction
- Pre-trained model included (model.h5)
yoga-pose-classifier/
├── DATASET/
│ ├── TRAIN/ # Training images organized by pose
│ │ ├── downdog/
│ │ ├── goddess/
│ │ ├── plank/
│ │ ├── tree/
│ │ └── warrior2/
│ └── TEST/ # Test images organized by pose
│ ├── downdog/
│ ├── goddess/
│ ├── plank/
│ ├── tree/
│ └── warrior2/
├── yoga_pose12s.ipynb # Main training notebook
├── Main.py # Inference script
├── model.h5 # Pre-trained model
├── training_logs.csv # Training history
└── README.md
-
Clone the repository
git clone https://github.com/your-username/yoga-pose-classifier.git cd yoga-pose-classifier -
Install dependencies
pip install -r requirements.txt
-
Verify installation
python Main.py
The project uses a yoga poses dataset with:
- Training set: 1,081 images across 5 classes
- Test set: 470 images across 5 classes
- Image size: 150x150 pixels
- Classes: 5 different yoga poses
Dataset source: Yoga Poses Dataset on Kaggle
-
Open the Jupyter notebook:
jupyter notebook yoga_pose12s.ipynb
-
Run all cells to train the model from scratch
-
Using the inference script:
python Main.py
-
Using the model programmatically:
import tensorflow as tf import cv2 import numpy as np # Load the model model = tf.keras.models.load_model('model.h5') # Load and preprocess image image = cv2.imread('path/to/your/image.jpg') image = cv2.resize(image, (150, 150)) image = np.array(image).reshape(1, 150, 150, 3) # Make prediction prediction = model.predict(image)[0] # Convert to class name poses = {1: 'Downdog', 2: 'Goddess', 3: 'Plank', 4: 'Tree', 5: 'Warrior2'} predicted_pose = poses[np.argmax(prediction) + 1] print(f'Predicted pose: {predicted_pose}')
The CNN model consists of:
- Input Layer: 150x150x3 (RGB images)
- Convolutional Blocks: 4 blocks with increasing filter sizes (64, 128, 256, 256)
- Pooling: MaxPooling after each block
- Dropout: 0.2 dropout rate for regularization
- Dense Layers: Fully connected layers for classification
- Output: 5 classes with softmax activation
- Training Accuracy: High accuracy achieved during training
- Validation Accuracy: Good generalization on test set
- Training History: Available in
training_logs.csv
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Anuj Dev Singh
- Project Creator & Lead Developer
- Dataset provided by Niharika41298 on Kaggle
- Built with TensorFlow and Keras
- OpenCV for image processing
If you have any questions or suggestions, feel free to reach out!
Happy Coding! 🧘♂️✨