Spaces:
Sleeping
Sleeping
Diamond CSGO AI Player - Deployment Guide
๐ Deploying to Hugging Face Spaces
Prerequisites
- Hugging Face account
- Model checkpoint files (
agent_epoch_00206.ptor similar) - Git and Git LFS installed
Step 1: Prepare Repository
Clone/Fork this repository
Install Git LFS (for large model files):
git lfs install git lfs track "*.pt" git add .gitattributesAdd your model checkpoint:
# Copy your trained model to the project root cp /path/to/your/agent_epoch_00206.pt . git add agent_epoch_00206.pt git commit -m "Add trained model checkpoint"
Step 2: Create Hugging Face Space
- Go to Hugging Face Spaces
- Click "Create new Space"
- Configure:
- Space name:
diamond-csgo-ai(or your choice) - License: Your preferred license
- Space SDK:
Docker - Space hardware:
CPU basic(free) - for demo/testingGPU T4 small(paid) - for better performance
- Space name:
Step 3: Upload Code
# Clone your new space
git clone https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME
cd YOUR_SPACE_NAME
# Copy all project files
cp -r /path/to/diamond/* .
# Commit and push
git add .
git commit -m "Initial Diamond CSGO AI deployment"
git push
Step 4: Configuration Files
Ensure these files are in your space root:
app.py- Main FastAPI applicationrequirements.txt- Python dependenciesDockerfile- Container configurationREADME.md- Space descriptionpackages.txt- System packages (if needed)
Step 5: Model Setup
If your model is too large for Git (>100MB), use Git LFS or download from Hub:
# In your app.py, add model downloading:
from huggingface_hub import hf_hub_download
def download_model():
return hf_hub_download(
repo_id="YOUR_USERNAME/YOUR_MODEL_REPO",
filename="agent_epoch_00206.pt"
)
๐ง Local Testing
Before deploying, test locally:
# Install dependencies
pip install -r requirements.txt
# Run tests
python test_web_app.py
# Start local server
python run_web_demo.py
Visit http://localhost:7860 to test the interface.
โ๏ธ Configuration Options
Hardware Requirements
| Tier | CPU | RAM | GPU | Performance |
|---|---|---|---|---|
| Free | 2 vCPU | 16GB | None | Basic demo |
| Basic GPU | 4 vCPU | 16GB | T4 | Good performance |
| Premium | 8 vCPU | 32GB | A10G | Best experience |
Environment Variables
Add these in your Space settings:
CUDA_VISIBLE_DEVICES=""(for CPU-only)PYTHONPATH="/app/src:/app"
๐ฎ Usage Instructions
Once deployed, users can:
- Visit your Space URL
- Click on the game canvas
- Use keyboard controls:
- WASD - Movement
- Space - Jump
- Arrow keys - Camera
- 1,2,3 - Weapons
- R - Reload
- M - Switch Human/AI mode
๐ Troubleshooting
Common Issues
Model not loading:
- Check checkpoint file exists
- Verify file size (<5GB for Spaces)
- Use Git LFS for large files
Import errors:
- Check
requirements.txtis complete - Verify Python path in
Dockerfile
- Check
Performance issues:
- Use GPU hardware tier
- Reduce model complexity
- Lower frame rate
WebSocket connection failed:
- Check firewall settings
- Verify port 7860 is accessible
- Try different browser
Debug Mode
Enable debug logging:
import logging
logging.basicConfig(level=logging.DEBUG)
๐ Monitoring
Monitor your Space:
- View logs in HF Spaces interface
- Check GPU utilization
- Monitor user sessions
๐ Updates
To update your deployed Space:
git pull # Get latest changes
git add .
git commit -m "Update to latest version"
git push # Automatically redeploys
๐ก Tips for Success
- Start with CPU tier to test basic functionality
- Use smaller models for faster loading
- Test thoroughly locally before deploying
- Monitor resource usage to optimize costs
- Add usage instructions in your Space README
๐ฏ Next Steps
After successful deployment:
- Share your Space with the community
- Collect user feedback
- Iterate on the interface
- Add new features like replay saving
- Consider multi-user support
Happy deploying! ๐