Spaces:
Sleeping
Sleeping
File size: 3,307 Bytes
ff03012 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# 🚀 Guide de Déploiement Hugging Face Spaces
## 📋 Scripts Disponibles
### 1. `check_hf_space.sh` - Vérification Pré-Déploiement
Vérifie que tout est prêt avant de déployer:
```bash
./check_hf_space.sh
```
**Vérifie:**
- ✅ Python version (>= 3.12)
- ✅ Fichiers requis (app.py, requirements.txt, etc.)
- ✅ Répertoires requis (detection/, api/, ui/, rfdetr/)
- ✅ model.pth présent et tracké par Git LFS
- ✅ Configuration Git LFS
- ✅ Métadonnées README.md (frontmatter YAML)
- ✅ requirements.txt complet
- ✅ Syntaxe Python valide
- ✅ Configuration Git et remote HF
- ✅ Connexion Hugging Face CLI
### 2. `deploy_hf_space.sh` - Déploiement Automatique
Déploie automatiquement vers Hugging Face Spaces:
```bash
./deploy_hf_space.sh
```
**Fait automatiquement:**
- ✅ Configure Git LFS pour model.pth
- ✅ Vérifie/configure le remote HF
- ✅ Vérifie la connexion HF
- ✅ Met à jour requirements.txt si nécessaire
- ✅ Stage tous les fichiers
- ✅ Commit avec message descriptif
- ✅ Push vers HF Spaces
- ✅ Affiche l'URL du Space
## 🎯 Workflow Recommandé
### Étape 1: Vérifier
```bash
./check_hf_space.sh
```
**Résultat attendu:**
```
✅ All checks passed! Ready to deploy! ✨
```
### Étape 2: Déployer
```bash
./deploy_hf_space.sh
```
Le script va:
1. Vérifier Git LFS
2. Configurer le remote si nécessaire
3. Vérifier la connexion HF
4. Commit et push
5. Afficher l'URL du Space
### Étape 3: Suivre le Build
Le script affichera l'URL de votre Space:
```
https://huggingface.co/spaces/YOUR_USERNAME/CU1-X
```
Cliquez sur **"Logs"** pour voir le build en direct.
## 📡 Accéder à l'API
Une fois déployé, votre API est accessible via:
### API Gradio Native
```python
from gradio_client import Client
client = Client("AI-DrivenTesting/CU1-X")
result = client.predict(
"screenshot.png",
0.35, 2, True, True, False, False, "Only image & button",
False, "RF-DETR Optimized (Recommended)", "standard",
api_name="/predict"
)
```
**Voir:** `API_USAGE.md` pour plus de détails
## 🔧 Dépannage
### Erreur: "Git LFS not installed"
```bash
# macOS
brew install git-lfs
git lfs install
# Linux
sudo apt install git-lfs
git lfs install
```
### Erreur: "Not logged in"
```bash
hf login
# OU
huggingface-cli login
```
### Erreur: "model.pth not tracked by LFS"
```bash
git lfs track "*.pth"
git add .gitattributes model.pth
git commit -m "Add model with LFS"
```
### Erreur: "No remote configured"
Le script `deploy_hf_space.sh` vous demandera de configurer le remote automatiquement.
Ou manuellement:
```bash
git remote add origin https://huggingface.co/spaces/YOUR_USERNAME/CU1-X
```
## 📊 Checklist Rapide
Avant de déployer:
- [ ] `./check_hf_space.sh` passe tous les tests
- [ ] Git LFS installé et configuré
- [ ] Connecté à Hugging Face (`hf login`)
- [ ] model.pth présent (~510MB)
- [ ] Remote HF configuré
Pour déployer:
```bash
./deploy_hf_space.sh
```
## 🎉 Après le Déploiement
Votre Space sera accessible à:
- **Interface Web:** `https://huggingface.co/spaces/YOUR_USERNAME/CU1-X`
- **API:** `https://YOUR_USERNAME-CU1-X.hf.space/api/predict`
**Temps de build:** 5-10 minutes (première fois)
---
**Besoin d'aide?** Consultez `API_USAGE.md` pour utiliser l'API!
|