Spaces:
Sleeping
Sleeping
Peter Michael Gits Claude commited on
Commit Β·
4561284
1
Parent(s): 74e87c5
feat: Add HuggingFace authentication to increase ZeroGPU quota
Browse files- Added HF_TOKEN environment variable support for authentication
- Automatic login to HuggingFace on service startup
- Added huggingface_hub dependency to requirements
- Debug logging shows authentication status
- This should eliminate '429 Too Many Requests' ZeroGPU quota errors
Usage: Set HF_TOKEN secret in HuggingFace Space settings with your token
π€ Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- app.py +13 -0
- requirements.txt +2 -1
app.py
CHANGED
|
@@ -355,6 +355,19 @@ if __name__ == "__main__":
|
|
| 355 |
logger.info(f"π€ DEBUG: Device: {device}")
|
| 356 |
logger.info(f"π€ DEBUG: Model size: {model_size}")
|
| 357 |
logger.info(f"π€ DEBUG: Default language: English (en)")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 358 |
logger.info(f"π€ DEBUG: Service ready for connections")
|
| 359 |
|
| 360 |
# Create FastAPI app for WebSocket endpoints
|
|
|
|
| 355 |
logger.info(f"π€ DEBUG: Device: {device}")
|
| 356 |
logger.info(f"π€ DEBUG: Model size: {model_size}")
|
| 357 |
logger.info(f"π€ DEBUG: Default language: English (en)")
|
| 358 |
+
|
| 359 |
+
# Login to HuggingFace to get more ZeroGPU quota
|
| 360 |
+
try:
|
| 361 |
+
from huggingface_hub import login
|
| 362 |
+
hf_token = os.getenv('HF_TOKEN')
|
| 363 |
+
if hf_token:
|
| 364 |
+
login(token=hf_token)
|
| 365 |
+
logger.info(f"π DEBUG: HuggingFace authentication successful")
|
| 366 |
+
else:
|
| 367 |
+
logger.warning(f"β οΈ DEBUG: No HF_TOKEN found - using anonymous access (limited quota)")
|
| 368 |
+
except Exception as e:
|
| 369 |
+
logger.error(f"β DEBUG: HuggingFace login failed: {e}")
|
| 370 |
+
|
| 371 |
logger.info(f"π€ DEBUG: Service ready for connections")
|
| 372 |
|
| 373 |
# Create FastAPI app for WebSocket endpoints
|
requirements.txt
CHANGED
|
@@ -9,4 +9,5 @@ numpy>=1.21.0
|
|
| 9 |
soundfile>=0.12.0
|
| 10 |
fastapi>=0.104.0
|
| 11 |
uvicorn>=0.24.0
|
| 12 |
-
python-multipart>=0.0.6
|
|
|
|
|
|
| 9 |
soundfile>=0.12.0
|
| 10 |
fastapi>=0.104.0
|
| 11 |
uvicorn>=0.24.0
|
| 12 |
+
python-multipart>=0.0.6
|
| 13 |
+
huggingface_hub>=0.17.0
|