gbaladi / PoseClassifier-yolo

Classify human poses with help of yolo pose model.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PoseClassifier-yolo


Classify human poses with help of yolo pose model.

πŸ–ΌοΈ Sample Output

output

Let's Get Started...

Using this Custom Pose Classification, I am going to Create a Yoga Pose Classification. Using Yoga Poses Dataset.

Clone this Repository

git clone https://github.com/naseemap47/PoseClassifier-yolo.git
cd PoseClassifier-yolo

Install Dependency

Recommended:

conda create -n pose python=3.9 -y
conda activate pose
conda install pytorch==2.0.0 torchvision==0.15.0 torchaudio==2.0.0 pytorch-cuda=11.8 -c pytorch -c nvidia -y
pip3 install -r requirements.txt

OR

pip3 install -r requirements.txt

πŸŽ’ Prepare Dataset

Dataset Structure:

β”œβ”€β”€ Dataset
β”‚   β”œβ”€β”€ class1
β”‚   β”‚   β”œβ”€β”€ 1.jpg
β”‚   β”‚   β”œβ”€β”€ 2.jpg
β”‚   β”‚   β”œβ”€β”€ ...
β”‚   β”œβ”€β”€ class2
β”‚   β”‚   β”œβ”€β”€ 1.jpg
β”‚   β”‚   β”œβ”€β”€ 2.jpg
β”‚   β”‚   β”œβ”€β”€ ...
.   .
.   .

πŸ€– Train

πŸ—ƒοΈ Create Landmark Dataset for each Classes

Convert pose images into pose lankmark and save to an CSV file. So that we can train with that.

Args

-p, --pose: choose yolov8 pose model
Choices: yolov8n-pose, yolov8s-pose, yolov8m-pose, yolov8l-pose, yolov8x-pose, yolov8x-pose-p6
-i, --data: path to data Dir
-o, --save: path to save csv file, eg: dir/data.csv

Example:

python3 generate_csv.py --pose yolov8n-pose --data dataset/train_data --save data.csv

πŸš† Create DeepLearinng Model to predict Human Pose

Create a keras model to predict human poses.

Args

-i, --data: path to data Dir

Example:

python3 train.py --data data.csv

πŸ“Ί Inference

Inference your Pose model.

Support

  • Image
  • Video
  • Camera
  • RTSP
Args

-p, --pose: choose yolov8 pose model
Choices: yolov8n-pose, yolov8s-pose, yolov8m-pose, yolov8l-pose, yolov8x-pose, yolov8x-pose-p6
-m, --model: path to saved keras model
-s, --source: video path/cam-id/RTSP
-c, --conf: model prediction confidence (0<conf<1)
--save: to save video
--hide: hide video window

Example:

python3 inference.py --pose yolov8n-pose --weight /runs/train4/ckpt_best.pth --source /test/video.mp4 --conf 0.66           # video
                                                                             --source /test/sample.jpg --conf 0.5 --save    # Image save
                                                                             --source /test/video.mp4 --conf 0.75 --hide    # to save and hide video window
                                                                             --source 0 --conf 0.45                         # Camera
                                                                             --source 'rtsp://link' --conf 0.25 --save      # save RTSP video stream

About

Classify human poses with help of yolo pose model.

License:MIT License


Languages

Language:Python 97.8%Language:Dockerfile 2.2%