Spaces:
Runtime error
Runtime error
Delete DEPLOY_TO_HF.md
Browse files- DEPLOY_TO_HF.md +0 -313
DEPLOY_TO_HF.md
DELETED
|
@@ -1,313 +0,0 @@
|
|
| 1 |
-
# ๐ Deploy to HuggingFace Spaces
|
| 2 |
-
|
| 3 |
-
Complete guide for deploying the Seamless Translation AI Agent to HuggingFace Spaces.
|
| 4 |
-
|
| 5 |
-
## ๐ Prerequisites
|
| 6 |
-
|
| 7 |
-
1. **HuggingFace Account**: Create account at [huggingface.co](https://huggingface.co)
|
| 8 |
-
2. **Git (Optional)**: For command-line deployment
|
| 9 |
-
3. **Files Ready**: All required files in this directory
|
| 10 |
-
|
| 11 |
-
## ๐ ๏ธ Pre-Deployment Testing
|
| 12 |
-
|
| 13 |
-
Run local tests before deployment:
|
| 14 |
-
|
| 15 |
-
```bash
|
| 16 |
-
# Test all functionality
|
| 17 |
-
python test_local.py
|
| 18 |
-
|
| 19 |
-
# Run examples to verify features
|
| 20 |
-
python examples.py
|
| 21 |
-
|
| 22 |
-
# Test locally (optional)
|
| 23 |
-
python app.py
|
| 24 |
-
```
|
| 25 |
-
|
| 26 |
-
## ๐ Method 1: Web Interface Deployment (Recommended)
|
| 27 |
-
|
| 28 |
-
### Step 1: Create New Space
|
| 29 |
-
1. Go to [HuggingFace Spaces](https://huggingface.co/spaces)
|
| 30 |
-
2. Click **"Create new Space"**
|
| 31 |
-
3. Fill in details:
|
| 32 |
-
- **Space name**: `seamless-translation-ai-agent`
|
| 33 |
-
- **License**: `MIT`
|
| 34 |
-
- **SDK**: `Gradio`
|
| 35 |
-
- **Hardware**: `GPU Basic` (recommended) or `CPU Basic`
|
| 36 |
-
- **Visibility**: `Public`
|
| 37 |
-
|
| 38 |
-
### Step 2: Upload Files
|
| 39 |
-
Upload these files to your Space:
|
| 40 |
-
|
| 41 |
-
**Required Files:**
|
| 42 |
-
- `app.py` - Main application
|
| 43 |
-
- `requirements.txt` - Dependencies
|
| 44 |
-
- `README.md` - Documentation
|
| 45 |
-
|
| 46 |
-
**Optional Files (recommended):**
|
| 47 |
-
- `config.py` - Configuration
|
| 48 |
-
- `utils.py` - Utilities
|
| 49 |
-
- `examples.py` - Usage examples
|
| 50 |
-
- `Dockerfile` - Container config
|
| 51 |
-
|
| 52 |
-
### Step 3: Configuration
|
| 53 |
-
1. Go to **Settings** tab
|
| 54 |
-
2. Set **Hardware** to `GPU Basic` for best performance
|
| 55 |
-
3. Enable **Auto-build** if desired
|
| 56 |
-
4. Set any required **Environment Variables** (if needed):
|
| 57 |
-
```
|
| 58 |
-
HUGGING_FACE_HUB_TOKEN=your_token_here (optional)
|
| 59 |
-
```
|
| 60 |
-
|
| 61 |
-
### Step 4: Launch
|
| 62 |
-
1. Space will automatically build and deploy
|
| 63 |
-
2. Monitor **Logs** tab for any issues
|
| 64 |
-
3. Visit your Space URL when ready
|
| 65 |
-
|
| 66 |
-
## ๐ป Method 2: Git Deployment
|
| 67 |
-
|
| 68 |
-
### Step 1: Clone Space Repository
|
| 69 |
-
```bash
|
| 70 |
-
# Replace with your space name
|
| 71 |
-
git clone https://huggingface.co/spaces/your-username/seamless-translation-ai-agent
|
| 72 |
-
cd seamless-translation-ai-agent
|
| 73 |
-
```
|
| 74 |
-
|
| 75 |
-
### Step 2: Add Files
|
| 76 |
-
```bash
|
| 77 |
-
# Copy all files to the repository
|
| 78 |
-
cp path/to/your/files/* .
|
| 79 |
-
|
| 80 |
-
# Add files to git
|
| 81 |
-
git add .
|
| 82 |
-
git commit -m "Initial deployment of Seamless Translation AI Agent"
|
| 83 |
-
```
|
| 84 |
-
|
| 85 |
-
### Step 3: Push to HuggingFace
|
| 86 |
-
```bash
|
| 87 |
-
git push origin main
|
| 88 |
-
```
|
| 89 |
-
|
| 90 |
-
## ๐ง Configuration Options
|
| 91 |
-
|
| 92 |
-
### Hardware Options
|
| 93 |
-
|
| 94 |
-
| Hardware | RAM | GPU | Cost | Best For |
|
| 95 |
-
|----------|-----|-----|------|----------|
|
| 96 |
-
| CPU Basic | 16GB | None | Free | Text translation only |
|
| 97 |
-
| GPU Basic | 16GB | T4 | $0.6/hour | Full functionality |
|
| 98 |
-
| GPU A10G | 24GB | A10G | $3.15/hour | High performance |
|
| 99 |
-
|
| 100 |
-
**Recommendation**: Start with GPU Basic for full functionality.
|
| 101 |
-
|
| 102 |
-
### Environment Variables
|
| 103 |
-
|
| 104 |
-
Set in Space Settings > Repository secrets:
|
| 105 |
-
|
| 106 |
-
```bash
|
| 107 |
-
# Optional: HuggingFace token for private models
|
| 108 |
-
HUGGING_FACE_HUB_TOKEN=hf_your_token_here
|
| 109 |
-
|
| 110 |
-
# Optional: CUDA device selection
|
| 111 |
-
CUDA_VISIBLE_DEVICES=0
|
| 112 |
-
|
| 113 |
-
# Optional: Model cache directory
|
| 114 |
-
TRANSFORMERS_CACHE=/tmp/transformers_cache
|
| 115 |
-
```
|
| 116 |
-
|
| 117 |
-
### Model Configuration
|
| 118 |
-
|
| 119 |
-
Edit `config.py` to customize models:
|
| 120 |
-
|
| 121 |
-
```python
|
| 122 |
-
# Use smaller models for faster loading
|
| 123 |
-
TRANSLATION_MODEL = "facebook/nllb-200-distilled-600M" # Default
|
| 124 |
-
# TRANSLATION_MODEL = "facebook/nllb-200-1.3B" # Better quality
|
| 125 |
-
|
| 126 |
-
SPEECH_RECOGNITION_MODEL = "openai/whisper-base" # Default
|
| 127 |
-
# SPEECH_RECOGNITION_MODEL = "openai/whisper-small" # Better quality
|
| 128 |
-
```
|
| 129 |
-
|
| 130 |
-
## ๐ Performance Optimization
|
| 131 |
-
|
| 132 |
-
### 1. Model Selection
|
| 133 |
-
- **Small models**: Faster loading, less GPU memory
|
| 134 |
-
- **Large models**: Better quality, more GPU memory
|
| 135 |
-
|
| 136 |
-
### 2. Hardware Selection
|
| 137 |
-
- **CPU Basic**: Free, text-only functionality
|
| 138 |
-
- **GPU Basic**: Recommended for full features
|
| 139 |
-
- **GPU A10G**: Best performance for heavy usage
|
| 140 |
-
|
| 141 |
-
### 3. Caching Strategy
|
| 142 |
-
```python
|
| 143 |
-
# In config.py, adjust cache settings
|
| 144 |
-
CACHE_CONFIG = {
|
| 145 |
-
"translation_cache_size": 1000, # Increase for better caching
|
| 146 |
-
"cache_ttl": 3600 # 1 hour cache lifetime
|
| 147 |
-
}
|
| 148 |
-
```
|
| 149 |
-
|
| 150 |
-
## ๐ Troubleshooting
|
| 151 |
-
|
| 152 |
-
### Common Issues
|
| 153 |
-
|
| 154 |
-
**1. Build Timeout**
|
| 155 |
-
```
|
| 156 |
-
Solution: Use smaller models or GPU hardware
|
| 157 |
-
- Switch to "whisper-base" instead of "whisper-large"
|
| 158 |
-
- Use "nllb-200-distilled-600M" instead of larger NLLB models
|
| 159 |
-
```
|
| 160 |
-
|
| 161 |
-
**2. Out of Memory**
|
| 162 |
-
```
|
| 163 |
-
Error: CUDA out of memory
|
| 164 |
-
Solution:
|
| 165 |
-
- Upgrade to GPU A10G hardware
|
| 166 |
-
- Reduce batch_size in config.py
|
| 167 |
-
- Use smaller models
|
| 168 |
-
```
|
| 169 |
-
|
| 170 |
-
**3. Model Download Fails**
|
| 171 |
-
```
|
| 172 |
-
Error: Model download timeout
|
| 173 |
-
Solution:
|
| 174 |
-
- Retry deployment
|
| 175 |
-
- Check internet connection in Space logs
|
| 176 |
-
- Use HuggingFace token for private models
|
| 177 |
-
```
|
| 178 |
-
|
| 179 |
-
**4. Audio Processing Errors**
|
| 180 |
-
```
|
| 181 |
-
Error: librosa/soundfile issues
|
| 182 |
-
Solution:
|
| 183 |
-
- Ensure all audio dependencies in requirements.txt
|
| 184 |
-
- Check ffmpeg availability
|
| 185 |
-
- Use supported audio formats only
|
| 186 |
-
```
|
| 187 |
-
|
| 188 |
-
### Debug Steps
|
| 189 |
-
|
| 190 |
-
1. **Check Logs**: Space > Logs tab
|
| 191 |
-
2. **Test Locally**: Run `python test_local.py`
|
| 192 |
-
3. **Verify Files**: Ensure all required files uploaded
|
| 193 |
-
4. **Check Hardware**: GPU recommended for audio features
|
| 194 |
-
5. **Model Cache**: Clear and retry if models fail to load
|
| 195 |
-
|
| 196 |
-
## ๐ Monitoring & Analytics
|
| 197 |
-
|
| 198 |
-
### Built-in Metrics
|
| 199 |
-
The app includes performance tracking:
|
| 200 |
-
- Translation counts
|
| 201 |
-
- Processing times
|
| 202 |
-
- Error rates
|
| 203 |
-
- Uptime statistics
|
| 204 |
-
|
| 205 |
-
### HuggingFace Analytics
|
| 206 |
-
Monitor in Space settings:
|
| 207 |
-
- User visits
|
| 208 |
-
- API calls
|
| 209 |
-
- Resource usage
|
| 210 |
-
- Costs (for paid hardware)
|
| 211 |
-
|
| 212 |
-
## ๐ Updates & Maintenance
|
| 213 |
-
|
| 214 |
-
### Updating Your Space
|
| 215 |
-
|
| 216 |
-
**Method 1: Web Interface**
|
| 217 |
-
1. Edit files directly in Space interface
|
| 218 |
-
2. Save changes to trigger rebuild
|
| 219 |
-
|
| 220 |
-
**Method 2: Git Push**
|
| 221 |
-
```bash
|
| 222 |
-
# Make changes locally
|
| 223 |
-
git add .
|
| 224 |
-
git commit -m "Update models/features"
|
| 225 |
-
git push origin main
|
| 226 |
-
```
|
| 227 |
-
|
| 228 |
-
### Version Management
|
| 229 |
-
```python
|
| 230 |
-
# In config.py, update version
|
| 231 |
-
VERSION = "1.0.1"
|
| 232 |
-
|
| 233 |
-
# Add changelog to README.md
|
| 234 |
-
## Changelog
|
| 235 |
-
- v1.0.1: Improved audio processing
|
| 236 |
-
- v1.0.0: Initial release
|
| 237 |
-
```
|
| 238 |
-
|
| 239 |
-
## ๐ Post-Deployment
|
| 240 |
-
|
| 241 |
-
### 1. Test Your Space
|
| 242 |
-
- Visit your Space URL
|
| 243 |
-
- Test all features:
|
| 244 |
-
- Text translation
|
| 245 |
-
- Audio upload
|
| 246 |
-
- Live microphone
|
| 247 |
-
- Check different language pairs
|
| 248 |
-
|
| 249 |
-
### 2. Share Your Space
|
| 250 |
-
- Add to your HuggingFace profile
|
| 251 |
-
- Share on social media
|
| 252 |
-
- Submit to HuggingFace community
|
| 253 |
-
|
| 254 |
-
### 3. Monitor Performance
|
| 255 |
-
- Check logs regularly
|
| 256 |
-
- Monitor resource usage
|
| 257 |
-
- Update models as needed
|
| 258 |
-
|
| 259 |
-
## ๐ Advanced Features
|
| 260 |
-
|
| 261 |
-
### Custom Domain (Pro)
|
| 262 |
-
```bash
|
| 263 |
-
# For HuggingFace Pro users
|
| 264 |
-
# Configure custom domain in Space settings
|
| 265 |
-
# Point DNS to HuggingFace Spaces
|
| 266 |
-
```
|
| 267 |
-
|
| 268 |
-
### API Integration
|
| 269 |
-
```python
|
| 270 |
-
# Your Space automatically gets an API endpoint
|
| 271 |
-
import requests
|
| 272 |
-
|
| 273 |
-
response = requests.post(
|
| 274 |
-
"https://your-username-seamless-translation-ai-agent.hf.space/api/predict",
|
| 275 |
-
json={"data": ["Hello world", "en", "es"]}
|
| 276 |
-
)
|
| 277 |
-
```
|
| 278 |
-
|
| 279 |
-
### Embedding in Websites
|
| 280 |
-
```html
|
| 281 |
-
<!-- Embed your Space in any website -->
|
| 282 |
-
<iframe
|
| 283 |
-
src="https://your-username-seamless-translation-ai-agent.hf.space"
|
| 284 |
-
width="100%"
|
| 285 |
-
height="600"
|
| 286 |
-
frameborder="0">
|
| 287 |
-
</iframe>
|
| 288 |
-
```
|
| 289 |
-
|
| 290 |
-
## ๐ Support
|
| 291 |
-
|
| 292 |
-
- **HuggingFace Forums**: [discuss.huggingface.co](https://discuss.huggingface.co)
|
| 293 |
-
- **Documentation**: [huggingface.co/docs/hub/spaces](https://huggingface.co/docs/hub/spaces)
|
| 294 |
-
- **Discord**: HuggingFace Discord server
|
| 295 |
-
- **Issues**: Create issue in your Space repository
|
| 296 |
-
|
| 297 |
-
---
|
| 298 |
-
|
| 299 |
-
## โ
Deployment Checklist
|
| 300 |
-
|
| 301 |
-
- [ ] HuggingFace account created
|
| 302 |
-
- [ ] Local tests passing (`python test_local.py`)
|
| 303 |
-
- [ ] Space created with correct SDK (Gradio)
|
| 304 |
-
- [ ] All required files uploaded
|
| 305 |
-
- [ ] Hardware set to GPU Basic or higher
|
| 306 |
-
- [ ] Space successfully built and running
|
| 307 |
-
- [ ] All features tested in deployed Space
|
| 308 |
-
- [ ] README.md updated with Space URL
|
| 309 |
-
- [ ] Space made public (if desired)
|
| 310 |
-
|
| 311 |
-
**๐ Congratulations! Your AI Agent is now live on HuggingFace Spaces!**
|
| 312 |
-
|
| 313 |
-
**Space URL**: `https://huggingface.co/spaces/your-username/seamless-translation-ai-agent`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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