Real-time object tracking using SiamRPN (Siamese Region Proposal Network) with PyTorch.
- Python 3.10+
- PyTorch 1.9+
- OpenCV 4.5+
- FFmpeg (for video encoding)
pip install -r requirements.txtFiles Required:
app.py- FastAPI serversiamrpn.py- Tracker implementationmodel.pth- Pre-trained weightsrequirements.txt- DependenciesDockerfile- Container configurationREADME_HF.md- Space metadata
Files NOT Needed:
colab_api.py❌VisioTrack_Colab.ipynb❌README.md❌
Deploy:
- Create new Space on Hugging Face
- Select Docker SDK
- Upload required files
- Rename
README_HF.mdtoREADME.mdin the Space - Space will auto-deploy at
https://username-spacename.hf.space
Files Required:
VisioTrack_Colab.ipynb- Main notebookcolab_api.py- Flask serversiamrpn.py- Tracker implementationmodel.pth- Pre-trained weightsrequirements.txt- Dependencies
Files NOT Needed:
app.py❌Dockerfile❌README_HF.md❌README.md❌
Deploy:
- Upload files to Google Colab
- Open
VisioTrack_Colab.ipynb - Enable GPU: Runtime → Change runtime type → T4 GPU
- Run all cells
- Copy ngrok URL from output
- Use URL in frontend configuration
# Run FastAPI server
uvicorn app:app --host 0.0.0.0 --port 7860
# Or run Flask server (for Colab testing)
python colab_api.pyTrack object in video with bounding box.
Parameters:
video(file) - Video filebbox_x(int) - X coordinatebbox_y(int) - Y coordinatebbox_w(int) - Widthbbox_h(int) - Height
Response: Processed video with tracking visualization
Health check and GPU status
API documentation (FastAPI only)
curl -X POST "http://localhost:7860/track" \
-F "video=@test_video.mp4" \
-F "bbox_x=100" \
-F "bbox_y=100" \
-F "bbox_w=200" \
-F "bbox_h=200" \
-o tracked_output.mp4- SiamRPN Model - 5-layer CNN with Region Proposal Network
- Tracker - Frame-by-frame object localization
- Video Processing - OpenCV + FFmpeg pipeline
- API Server - FastAPI (HF) / Flask (Colab)
Model parameters in siamrpn.py:
exemplar_sz: 127 (template size)instance_sz: 271 (search region size)penalty_k: 0.055 (scale penalty)window_influence: 0.42 (smoothing)lr: 0.295 (learning rate for updates)
© 2025 BV Tech Team. All rights reserved.