CoolFace
Apppublic

Koti05/Cat-Dog-Pandas

sourceHugging Faceupdated 11mo agoView on Hugging Face
0likes
App README

๐Ÿพ Cat-Dog-Pandas Classifier

A Streamlit web app that uses PyTorch and transfer learning (AlexNet) to classify images of Cats ๐Ÿฑ, Dogs ๐Ÿถ, and Pandas ๐Ÿผ in real time. Deployed using Docker on Hugging Face Spaces.


๐Ÿง  Model Overview

  • โ€”Base Model: AlexNet (Transfer Learning)
  • โ€”Fine-tuned Layers: Layer4 + Fully Connected layers
  • โ€”Custom Classifier:
  • โ€”Linear(2048 โ†’ 512) + ReLU + Dropout(0.7)
  • โ€”Linear(512 โ†’ 128) + ReLU + Dropout(0.3)
  • โ€”Linear(128 โ†’ 3) [Output Layer]
  • โ€”Classes: Cat, Dog, Panda
  • โ€”Auto-Download: Model (model.pth) fetched automatically from Hugging Face
  • โ€”Device Support: CPU/GPU auto-detection

๐Ÿ“Š Performance Summary

MetricCatDogPandaMacro AvgWeighted Avg
Precision98.51%99.49%100.00%99.33%99.33%
Recall99.50%98.50%100.00%99.33%99.33%
F1-Score99.00%98.99%100.00%99.33%99.33%
Test Accuracyโ€“โ€“โ€“99.33%โ€“

๐Ÿ“ Project Structure

Cat-Dog-Pandas/ โ”œโ”€โ”€ ๐Ÿณ Dockerfile โ”œโ”€โ”€ ๐Ÿ“ฑ app.py โ”œโ”€โ”€ ๐Ÿ“ˆ metrics.json โ”œโ”€โ”€ ๐Ÿง  model.pth โ”œโ”€โ”€ ๐Ÿ““ Project.ipynb โ”œโ”€โ”€ ๐Ÿ“‹ requirements.txt โ”œโ”€โ”€ ๐Ÿ–ผ๏ธ confusion_matrix.png โ””โ”€โ”€ ๐Ÿ”ง datasplit.py


โš™๏ธ Dockerfile (Used in this Project)

dockerfile
FROM python:3.9-slim

WORKDIR /app

RUN apt-get update && apt-get install -y \
    build-essential \
    curl \
    git \
    && rm -rf /var/lib/apt/lists/*

COPY requirements.txt .

RUN pip3 install --no-cache-dir -r requirements.txt

COPY . .

RUN useradd -m -u 1000 user && \
    chown -R user:user /app
USER user

EXPOSE 7860

HEALTHCHECK CMD curl --fail http://localhost:7860/_stcore/health

CMD ["streamlit","run","app.py","--server.port=7860","--server.address=0.0.0.0","--server.enableXsrfProtection=false","--server.enableCORS=false","--server.maxUploadSize=50"]
---