Skip to content

peiva-git/basketball_detector

Repository files navigation

Basketball Detector

build and deploy docs build and test GPU build and test CPU License

🏀 BasketballDetector is a deep-learning based tool that enables automatic ball detection in basketball broadcasting videos.

Detections video example

The complete video is available here.

Table of contents

  1. Description
  2. Project requirements
  3. Project setup
  4. Credits

Description

This project uses the BasketballTrainer package to train a BasketballDetector model. This repository provides all the necessary tools to perform inference on the trained model using the FastDeploy API. In the following sections, you will find detailed instructions on how to set up a working environment and how to use one a trained model to predict the ball location.

Project requirements

  • Python 3.8/3.9/3.10/3.11
  • CUDA >= 11.2, cuDNN >= 8.0

A GPU with CUDA capabilities is recommended. Depending on your hardware and/or your OS, you might need different drivers: check out Nvidia's official website.

Project setup

The recommended approach is to use one of the two provided conda environments made available here, one CPU based and the second GPU based. Please note that, if you're installing the dependencies directly with pip, an additional index source needs to be specified. That is, you need to run the following command to install the package in development mode:

pip install -f https://www.paddlepaddle.org.cn/whl/fastdeploy.html -e .

By default, the GPU based environment uses the cudatoolkit=11.2 and cudnn=8.2 conda-forge packages. If you want to use a different CUDA version, refer to the official documentation.

All the requirements are listed in the requirements.txt file. To create a new conda environment meeting all the required dependencies, run the following command:

conda create --name myenv-fd --file fd-[gpu|cpu].yml

In case you're using the GPU version, don't forget to set up the required environment variables as well:

export LD_LIBRARY_PATH=$CONDA_PREFIX/lib/:$LD_LIBRARY_PATH

You can automate the process of adding the environment variables to execute automatically each time you activate your conda environment by running the following commands:

mkdir -p $CONDA_PREFIX/etc/conda/activate.d
echo 'export LD_LIBRARY_PATH=$CONDA_PREFIX/lib/:$LD_LIBRARY_PATH' >> $CONDA_PREFIX/etc/conda/activate.d/env_vars.sh

These environments have been tested under the following conditions:

  • Ubuntu 22.04 LTS
  • NVIDIA driver version 535.104.05 (installed from the CUDA toolkit repository)
  • Driver API CUDA version 12.2 (installed automatically along with the driver)

Making predictions

For information on how to use the package to make predictions with the model, refer to the official documentation.

Credits

This project uses pdoc to generate its documentation. All credits go to its authors.