BakoAI / SETUP_COMPLETE.md
Okidi Norbert
Deployment fix: clean backend only
c6abe34
# πŸ€ Basketball Analysis System - Setup Complete! βœ…
## System Status: READY FOR TESTING
Your basketball analysis system is now fully configured and ready to test with the pre-trained models from the [basketball_analysis repository](https://github.com/abdullahtarek/basketball_analysis).
---
## βœ… What's Been Set Up
### 1. **Pre-trained Models** (All Downloaded & Verified)
- βœ“ `player_detector.pt` (164.65 MB) - YOLO v11 player detection
- βœ“ `ball_detector_model.pt` (164.67 MB) - YOLO v5 ball detection
- βœ“ `court_keypoint_detector.pt` (398.37 MB) - YOLO v8 court keypoints
### 2. **Dependencies** (All Installed)
- βœ“ OpenCV 4.13.0
- βœ“ NumPy 2.3.5
- βœ“ Pandas 3.0.0
- βœ“ PyTorch 2.10.0+cpu (CPU version for compatibility)
- βœ“ Ultralytics 8.4.9
- βœ“ Supervision 0.27.0
- βœ“ Transformers 5.0.0
- βœ“ Pillow 12.0.0
### 3. **Test Videos Available**
- βœ“ video_1.mp4 (4.24 MB)
- βœ“ video_2.mp4 (6.69 MB)
- βœ“ video_3.mp4 (9.06 MB)
- βœ“ video_4.mp4 (6.60 MB)
### 4. **Testing Scripts Created**
- βœ“ `test_system.py` - Comprehensive system testing
- βœ“ `run.sh` - Convenient bash wrapper
- βœ“ `TESTING_GUIDE.md` - Detailed testing guide
- βœ“ `QUICK_REFERENCE.md` - Quick command reference
---
## πŸš€ Quick Start - Test the System Now!
### Option 1: Using the Convenience Script (Easiest)
```bash
# Navigate to back-end directory
cd /home/okidi6/Documents/Personalised-AI-Basketball-Skill-Analysis-System./back-end
# Run analysis on first test video
./run.sh input_videos/video_1.mp4
```
### Option 2: Using Python Directly
```bash
# Navigate to back-end directory
cd /home/okidi6/Documents/Personalised-AI-Basketball-Skill-Analysis-System./back-end
# Activate virtual environment
source venv/bin/activate
# Run analysis
python main.py input_videos/video_1.mp4
```
### Option 3: Using the Test Script
```bash
cd /home/okidi6/Documents/Personalised-AI-Basketball-Skill-Analysis-System./back-end
source venv/bin/activate
# Run full test
python test_system.py
```
---
## πŸ“Š What the Analysis Does
The system performs comprehensive basketball video analysis:
1. **Player Detection & Tracking** - Identifies and tracks all players
2. **Ball Detection & Tracking** - Tracks basketball with smooth interpolation
3. **Court Keypoint Detection** - Identifies court lines and zones
4. **Team Assignment** - Classifies players by jersey color
5. **Ball Possession** - Determines who has the ball
6. **Pass Detection** - Identifies passes between players
7. **Interception Detection** - Detects intercepted passes
8. **Tactical View** - Creates top-down mini-map
9. **Speed & Distance** - Calculates player movement metrics
### Output Features
The analyzed video will include:
- Player bounding boxes (color-coded by team)
- Ball tracking visualization
- Court keypoint overlays
- Team ball control statistics
- Pass and interception markers
- Tactical view (mini-map)
- Player speed and distance metrics
- Frame numbers
---
## ⏱️ Expected Processing Time
### First Run (No Cached Data)
- **CPU Only**: ~5-15 minutes per minute of video
- The system will create "stubs" (cached intermediate results)
### Subsequent Runs (With Cached Data)
- **Much Faster**: Reuses cached player/ball detections
- Only recomputes final visualization
### Performance Tips
- Start with short clips (10-30 seconds) for faster testing
- Keep the `stubs/` directory for faster re-runs
- Delete `stubs/` to force fresh analysis
---
## πŸ“ Output Location
Analyzed videos will be saved to:
```
/home/okidi6/Documents/Personalised-AI-Basketball-Skill-Analysis-System./back-end/output_videos/
```
Default output filename: `output_video.avi` (or custom name if specified)
---
## πŸŽ₯ Adding Your Own Test Videos
1. Place basketball video files in:
```
/home/okidi6/Documents/Personalised-AI-Basketball-Skill-Analysis-System./back-end/input_videos/
```
2. Supported formats: `.mp4`, `.avi`
3. Recommended video characteristics:
- Resolution: 720p or 1080p
- Frame rate: 30fps or higher
- Clear view of basketball court
- Good lighting
- Stable camera angle
4. Run analysis:
```bash
./run.sh input_videos/your_video.mp4
```
---
## πŸ” System Verification
All checks passed βœ…:
- [x] All dependencies installed
- [x] All models present and loading correctly
- [x] Test videos available
- [x] Directory structure set up
- [x] Virtual environment configured
---
## πŸ“– Documentation
- **TESTING_GUIDE.md** - Comprehensive testing guide with troubleshooting
- **QUICK_REFERENCE.md** - Quick command reference
- **test_system.py** - Automated system testing
- **run.sh** - Convenience script for running analysis
---
## πŸ› Troubleshooting
### If you encounter issues:
1. **Ensure virtual environment is activated**:
```bash
source venv/bin/activate
```
2. **Check system status**:
```bash
python test_system.py --check-only
```
3. **View detailed logs**: Check console output for error messages
4. **Clear cache and retry**:
```bash
rm -rf stubs/
python main.py input_videos/video_1.mp4
```
---
## πŸ“ Notes
- **CPU vs GPU**: Currently using PyTorch CPU version for compatibility
- Processing will be slower than GPU but fully functional
- If you have CUDA-capable GPU and want to use it, you can reinstall PyTorch with CUDA support
- **Stub Caching**: The system caches intermediate results in `stubs/`
- First run: Slower (creates cache)
- Subsequent runs: Much faster (uses cache)
- Delete `stubs/` to force fresh analysis
- **Video Quality**: Better quality input videos = better detection results
- Clear court view
- Good lighting
- Stable camera
- Visible players and ball
---
## 🎯 Next Steps
### 1. Test the System (NOW!)
```bash
cd /home/okidi6/Documents/Personalised-AI-Basketball-Skill-Analysis-System./back-end
./run.sh input_videos/video_1.mp4
```
### 2. Review Output
- Check `output_videos/` for the analyzed video
- Verify all analysis features are working
- Test with different input videos
### 3. Integration Planning
Once testing is successful:
- Integrate with FastAPI backend
- Add video upload endpoints
- Implement async processing
- Store results in Supabase
- Connect to frontend
---
## πŸŽ‰ Ready to Go!
Your system is fully prepared and ready for testing. Run your first analysis now:
```bash
cd /home/okidi6/Documents/Personalised-AI-Basketball-Skill-Analysis-System./back-end
./run.sh input_videos/video_1.mp4
```
**Good luck with your testing! πŸ€**
---
## πŸ“ž Support Resources
- **TESTING_GUIDE.md** - Detailed testing instructions
- **QUICK_REFERENCE.md** - Command reference
- **Original Repository**: https://github.com/abdullahtarek/basketball_analysis
- **System Check**: `python test_system.py --check-only`
---
**System Status**: βœ… **READY FOR TESTING**
**Last Verified**: 2026-02-01 13:16 UTC
**All Systems**: βœ… **GO!**