Repo

Tennis-Analysis-System


Tennis-Analysis-System is a system that analyzes tennis matches and provides player statistics and mini court visualizations and It utilizes YOLO (You Only Look Once) v8x for player detection and tracking, and fine-tunes YOLOv5 for ball detection and tracking. Additionally, a ResNet50 model is used for keypoint detection and tracking.

Usage


  1. Clone the repository:
1
git clone https://github.com/Sh-31/Tennis-Analysis-System.git
  1. Install the required dependencies:
1
2
pip3 install -r requirements.txt (linux)
pip  install -r requirements.txt (windows)
  1. Run the main script:
1
2
python3 main.py (linux)
python main.py (windows)

Sample Output


Datasets


Ball Detection

For ball detection, we used the tennis-ball-detection dataset from Roboflow. You can access it at the following link:

Keypoint Detection

For keypoint detection, we used a dataset collected by yastrebksv. You can download it from the link below:

You can also download it using the code provided in the Tennis-Analysis-system\fine_tuning\explore.ipynb notebook.

Results


Fine-tuning YOLOv5 for Ball Detection

EpochTrain/Box LossTrain/Cls LossTrain/Dfl LossPrecision (B)Recall (B)Val/Box LossVal/Cls Loss
952.0520.947420.865130.761420.534651.99831.1024
961.99370.901070.834830.713850.469342.09441.1647
971.93960.880570.835430.734930.485152.17431.233
981.94610.927840.827940.728580.504972.12291.2019
991.89290.829870.830660.746480.495052.09711.1892
1001.9330.886270.845580.754460.495052.12421.1936

results YOLOv5 for Ball Detection

alt text

Fine-tuning ResNet50 for Keypoint Detection

alt text

Features


  • Player detection and tracking using YOLOv8
  • Ball detection and tracking using YOLOv5 (fine-tuned)
  • Keypoint detection and tracking using a Resnet50 model (fine-tuned)
  • Mini court visualizations with player and ball positions
  • Player statistics calculation

Limitations


  • Mini-court coordination is not generic (It needs the true height of the player to convert the proportion of meters to pixels).