Computer Vision of Players and Football using Yolo from Utltralytics
Yolov11 Models Link
2. Download Dataset in YOLO format
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
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
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.
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
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