This project involves building a custom object detection model using the YOLOv7 architecture to detect soccer players and classify whether they have possession of the ball. The dataset consists of approximately 1000 annotated images, and the model can process both images and videos.
- main.ipynb: The main Jupyter notebook containing all code and steps for data preparation, model training, and evaluation.
- Annotated Data: The annotated images with labels indicating whether the player has the ball or not.
All necessary files, including the dataset and trained model weights, can be accessed here: Google Drive Folder
- Navigate to
Edit
->Notebook settings
. - Select
GPU
from the hardware accelerator drop-down.
from google.colab import drive
drive.mount("/content/gdrive")
%cd /content/gdrive/MyDrive
import os
if not os.path.isdir("ML_project"):
os.makedirs("ML_project")
%cd ML_project
!git clone https://github.com/WongKinYiu/yolov7
%cd yolov7
!pip install -r requirements.txt
!wget https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7.pt
The notebook main.ipynb contains the code to train the YOLOv7 model on the soccer player dataset. Ensure that the dataset is correctly structured and located in the appropriate directory within your Google Drive.
After training, the model can accurately detect players with and without the ball in both images and videos. Example results, including detected photos and videos, are located at runs/detect/.
- The YOLOv7 repository: https://github.com/WongKinYiu/yolov7
- Google Colab for providing free GPU access.