AI Free Code

AI Basketball Analysis – AI Project

In this tutorial, we’ll build an Artificial Intelligence(AI) application named “AI Basketball Analysis” that is based on the concept of object detection. So, object detection helps to collect the data to analyze the shots of basketball digging. Through merely uploading files to the web app, or sending a POST request to the API, we can get the result. 

Project Features of AI Basketball Analysis Program

The project is mainly focus on three features they are: shot analysis, pose analysis, shot detection, and detection API

Shot analysis: Shot analysis is used to count scoring shots, missing shots, and attempts shot from the input video. Detection key points mentioned below have various definitions in different colors:-

  • a. Purple: Undetermined shot

  • b. Green: Shot went in

  • c. Blue: Detected basketball in normal condition

  • d. Red: Miss

Pose analysis: Pose analysis is used as the body tracking software named “OpenPose” to calculate the angle of knee and elbow during shooting.

Shot detection: Shot detection is used to calculate the coordinate and the confidence of the detection.

Detection API: Detection API is used to get the response from JSON by sending a POST request(./detection_json) with “image” as KEY and the ”Input Pictures”  as VALUE data. 

Detection Model
Figure: Detection Model

In this program, we have used the Faster R-CNN model architecture to train the object detection model which includes pre-trained weight on the COCO dataset. Finally, the configuration is taken from the model architecture and trained on our own dataset. 

Project Structure

Figure: Project Structure

Steps involved to run AI Basketball Analysis Program:

  • 1. Download the repository and unzip the files

  • 2. Install all required libraries and modules on your PC.

  • 3. Open the Python script named ‘’

  • 4. Run ‘’

  • 5. Enjoy AI Basketball analysis.


AI Basketball Analysis

Credit: Chonyy

3 thoughts on “AI Basketball Analysis – AI Project

Leave a Reply

Your email address will not be published. Required fields are marked *