Skip to content

πŸ€πŸ€–πŸ€ AI web app and API to analyze basketball shots and shooting pose.

License

Notifications You must be signed in to change notification settings

chonyy/AI-basketball-analysis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

91 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

AI Basketball Analysis

πŸ€ Analyze basketball shots and shooting pose with machine learning!

This is an AI-powered application focused on object detection to analyze basketball shots. The app allows users to upload basketball videos for analysis or submit POST requests to an API. Results include detailed shot and pose analysis based on object detection data. The project utilizes OpenPose to compute body keypoints and other metrics.


πŸ“– Project Overview

AI Basketball Analysis leverages artificial intelligence to break down basketball shots by detecting player movements, shot accuracy, and pose data. It uses the popular OpenPose framework for human pose estimation. Whether you're a developer or sports analyst, this project helps explore how AI can automate and enhance basketball analysis.

Important: This project is for noncommercial research use only, as it uses OpenPose's license. Please review the LICENSE for details.

If you're new to human pose estimation, check out this summary article that breaks down OpenPose's key concepts.


πŸš€ Getting Started

1. Clone the Repository

To get a copy of the project, run the following command:

git clone https://github.com/chonyy/AI-basketball-analysis.git

2. Install Dependencies

Before running the project, ensure all necessary dependencies are installed by running:

pip install -r requirements.txt

Note: This project requires a GPU with CUDA support to run OpenPose efficiently, especially for video analysis.

3. Run the Application

Once everything is set up, you can host the project locally with a simple command:

python app.py

This will launch the application locally, where you can upload basketball videos or images for analysis.

Hosting Options

If you'd prefer not to run the project locally, you can try these alternatives:

Google Colab (No GPU required!)

Thanks to hardik0, you can experiment with the AI Basketball Analysis in Google Colab without needing your own GPU: Google Colab Badge

Heroku Hosting

This project is also available on Heroku, though note that heavy computations like TensorFlow may cause timeout errors on Heroku due to limited resources. For best performance, it's recommended to run the app locally.


πŸ› οΈ Project Structure

Here’s a breakdown of the key components of the project:

  • app.py: Main file to run the web application.
  • /static: Contains all static assets like images, CSS, and JavaScript.
  • /models: Directory containing pre-trained models for object detection.
  • /scripts: Utility scripts for data processing and model training.

πŸ” Features

1. Shot and Pose Analysis

Shot Counting

Analyze basketball shots from the input video, determining successful and missed shots. Keypoints in different colors represent:

  • Blue: Detected basketball in normal status
  • Purple: Undetermined shot
  • Green: Successful shot
  • Red: Missed shot

Pose Analysis

Using OpenPose, the project analyzes the player's elbow and knee angles during a shot, helping determine release angles and times.

2. Shot Detection

This feature visualizes shot detection, showing confidence levels and coordinates for each detection.

3. Detection API

The project includes a REST API for detection, allowing you to submit images via a POST request and receive a JSON response with detected keypoints and other data.

POST /detection_json
  • KEY: image
  • VALUE: Input image

4. Detection Model

The model is based on the Faster R-CNN architecture, trained on the COCO dataset. For more details, refer to the TensorFlow Model Zoo.


πŸ”§ Future Plans

  • Transition the model to YOLOv4 for better performance.
  • Implement SORT tracking algorithm to filter false detections.
  • Improve visualization features for clearer results.
  • Optimize efficiency for better web app integration.

🀝 Contributing

We welcome contributions from the community! Here’s how you can get involved:

  1. Fork the repository
  2. Create a branch: git checkout -b feature/your-feature-name
  3. Commit your changes: git commit -m 'Add some feature'
  4. Push to the branch: git push origin feature/your-feature-name
  5. Open a Pull Request

For more information on contributing, visit Make A Pull Request.