Skip to content

EdwardChhun/soccer-prediction

Repository files navigation

Soccer Prediction using Computer Vision

Computer Vision of Players and Football using Yolo from Utltralytics
Yolov11 Models Link

Quick Start Guide

2. Download Dataset in YOLO format

image1

3. Select "show download code" and paste the content into a "download.py" file. Make sure to create your virtual environment (link on how to create a venv) and download the dependencies.

P.S. To train the model, you only need the code highlighted in the green box below, the code in red box is just to install the dependeny, remove it from your download.py file, I already have a requirements.txt compiled so just run

pip install -r requirements.txt

image2

4. Now create an environment file ".env", this is where you are going to keep your secret keys such as API keys. In this file you should have your API key set up as so

image3

This is a fake API key ofcourse, you need to have your own, and make sure that ".env" is in your ".gitignore" file, so whenever you push on to your GitHub repository, you won't leak any secret information.

Modify your download.py like so

From

image5

To

image4

5. Download your dataset by running the download.py file, and take a look and try to understand the data set and the file structure.

python download.py

6. Train your custom model on top of an existing pre-trained YOLO model

from ultralytics import YOLO


model = YOLO('yolo11s.pt')


# Training.
results = model.train(
   data=r'D:\Developer\soccer-prediction\Human-Detection-3\data.yaml', # Path to your data.yaml file
   imgsz=640,
   epochs=20,
   batch=8,
   save=True,
   device = "cpu", # Change to CUDA if you have CUDA Toolkit
   pretrained = True,
   project = r'D:\Developer\soccer-prediction', # Path to your working directory
   name='soccer_prediction')

7. Now run your model, go to image_inference.py and video_inference.py and test out the different images in assets/ folder, see the difference.

Yolo Predict Documentation

image6

image6_CV

About

Computer Vision of Players and Football using Yolov8

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages