Spaces:
Sleeping
Sleeping
| title: Pet Backend | |
| emoji: 🐶 | |
| colorFrom: blue | |
| colorTo: green | |
| sdk: docker | |
| app_port: 7860 | |
| pinned: false | |
| # Dog Breed Classification API | |
| Bu Hugging Face Space, **Pavarissy/ConvNextV2-large-DogBreed** modelini kullanarak köpek ırkı sınıflandırması yapan bir FastAPI backend'idir. | |
| ## 🚀 Kurulum Adımları | |
| ### 1. Hugging Face Space Oluşturma | |
| 1. https://huggingface.co/spaces adresine gidin | |
| 2. "Create new Space" butonuna tıklayın | |
| 3. Space adını girin: `petbackend` (veya istediğiniz bir isim) | |
| 4. SDK olarak **"Docker"** veya **"Gradio"** yerine **"Docker"** seçin (FastAPI için) | |
| 5. Space'i oluşturun | |
| ### 2. Dosyaları Yükleme | |
| Space oluşturulduktan sonra, bu klasördeki dosyaları Space'e yükleyin: | |
| - `app.py` - Ana FastAPI uygulaması | |
| - `requirements.txt` - Python bağımlılıkları | |
| - `Dockerfile` - Docker yapılandırması (aşağıda) | |
| ### 3. Dockerfile Oluşturma | |
| Space'inize bir `Dockerfile` eklemeniz gerekiyor: | |
| ```dockerfile | |
| FROM python:3.9 | |
| WORKDIR /code | |
| COPY ./requirements.txt /code/requirements.txt | |
| RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt | |
| COPY ./app.py /code/ | |
| CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] | |
| ``` | |
| ### 4. Alternatif: Gradio SDK Kullanımı | |
| Eğer Docker yerine Gradio SDK kullanmak isterseniz: | |
| 1. Space oluştururken SDK olarak "Gradio" seçin | |
| 2. Sadece `app.py` ve `requirements.txt` dosyalarını yükleyin | |
| 3. Hugging Face otomatik olarak FastAPI'yi çalıştıracaktır | |
| ## 📡 API Endpoints | |
| ### GET / | |
| Ana endpoint - API durumunu gösterir | |
| ```bash | |
| curl https://alpingo23-petbackend.hf.space/ | |
| ``` | |
| ### POST /predict_pet | |
| Köpek ırkı tahmini yapar | |
| ```bash | |
| curl -X POST https://alpingo23-petbackend.hf.space/predict_pet \ | |
| -F "image=@dog_image.jpg" | |
| ``` | |
| **Response Format:** | |
| ```json | |
| { | |
| "predicted_label": "n02085620-Chihuahua", | |
| "confidence": 0.95, | |
| "detection": { | |
| "box": { | |
| "x": 50.0, | |
| "y": 50.0, | |
| "width": 400.0, | |
| "height": 400.0 | |
| } | |
| }, | |
| "imageDimensions": { | |
| "width": 500, | |
| "height": 500 | |
| } | |
| } | |
| ``` | |
| ### GET /health | |
| Sağlık kontrolü endpoint'i | |
| ```bash | |
| curl https://alpingo23-petbackend.hf.space/health | |
| ``` | |
| ## 🔧 React Native Entegrasyonu | |
| App.js dosyanızda zaten doğru endpoint'i kullanıyorsunuz: | |
| ```javascript | |
| const res = await axios.post('https://alpingo23-petbackend.hf.space/predict_pet', formData, { | |
| headers: { 'Content-Type': 'multipart/form-data' }, | |
| }); | |
| ``` | |
| ## 🐛 Hata Ayıklama | |
| Space çalışmıyorsa: | |
| 1. **Logs kontrolü**: Space sayfasında "Logs" sekmesini kontrol edin | |
| 2. **Build durumu**: "Building" durumunda mı kontrol edin | |
| 3. **Model yükleme**: İlk açılışta model indirilir, 2-3 dakika sürebilir | |
| 4. **API testi**: `/health` endpoint'ini test edin | |
| ## 📝 Notlar | |
| - Model ilk yüklendiğinde indirme yapacağı için 2-3 dakika sürebilir | |
| - CORS tüm kaynaklardan gelen isteklere açık (production'da düzeltilmeli) | |
| - Detection box simülasyondur, gerçek nesne tespiti yapmaz | |
| - Model 120+ köpek ırkını tanıyabilir | |
| ## 🔗 Bağlantılar | |
| - Model: https://huggingface.co/Pavarissy/ConvNextV2-large-DogBreed | |
| - Space URL: https://alpingo23-petbackend.hf.space | |
| - Docs: https://alpingo23-petbackend.hf.space/docs (otomatik FastAPI docs) | |