CoolFace
Apppublic

Bihari04/pet-poultry-disease-classifier

sourceHugging Facemitupdated 5mo agoView on Hugging Face
0likes
App README

Pet Poultry Disease Classifier

This Hugging Face Space serves a trained PyTorch image classifier for pet and poultry disease detection.

What is in this folder

  • —app.py - Flask backend and model loading logic
  • —best_model.pth - trained checkpoint used for inference
  • —Dockerfile - container build for Hugging Face Spaces
  • —requirements.txt - runtime dependencies
  • —templates/index.html - frontend page
  • —static/css/style-a.css - page styles
  • —static/js/app-a.js - frontend interactivity
  • —.dockerignore - keeps the Docker build context small

What should be pushed

Push these to the Hugging Face Space repo and, if you want a backup copy, to GitHub too:

  • —app.py
  • —Dockerfile
  • —requirements.txt
  • —README.md
  • —best_model.pth
  • —templates/
  • —static/
  • —.dockerignore
  • —.gitattributes

What should not be pushed

Do not upload training-only or local-machine files to the Space:

  • —.venv/
  • —__pycache__/
  • —raw training datasets
  • —notebooks that are only for experimentation
  • —temporary logs, checkpoints, or export folders you do not use for inference
  • —local secrets, passwords, or tokens

One-time Hugging Face setup

  1. 1.Create an account at https://huggingface.co/join
  2. 2.Create a new Space
  3. 3.Choose Docker as the SDK
  4. 4.Set the Space name you want, for example pet-poultry-disease-classifier
  5. 5.Create a Write token at https://huggingface.co/settings/tokens

If you use Git from the terminal, log in once:

powershell
hf auth login

If hf is not on PATH, run the full path to hf.exe or add the Hugging Face scripts folder to PATH.

Git remotes

This project can push to two places:

  • —origin -> GitHub
  • —hf -> Hugging Face Space

Check them with:

powershell
git remote -v

If hf is missing, add it once:

powershell
git remote add hf https://huggingface.co/spaces/Bihari04/pet-poultry-disease-classifier

Normal update workflow

When you change frontend, backend, or model code:

  1. 1.Edit files in this hf-space folder.
  2. 2.Verify the repo is clean enough to commit:
powershell
git status
  1. 1.Commit your changes:
powershell
git add .
git commit -m "Update Space"
  1. 1.Push to GitHub if you want to keep a backup copy there:
powershell
git push origin main
  1. 1.Push to Hugging Face so the live Space rebuilds:
powershell
git push hf main

If the Space has changes on Hugging Face already

If Hugging Face rejects the push because the remote has new commits, sync first:

powershell
git pull hf main --rebase --allow-unrelated-histories
git push hf main

If there are merge conflicts, resolve them, run git add ., then continue the rebase:

powershell
git rebase --continue

Deployment steps

  1. 1.Create or open the Hugging Face Space.
  2. 2.Upload or push the contents of this folder.
  3. 3.Make sure best_model.pth is present in the Space repo.
  4. 4.Wait for the Docker build to finish.
  5. 5.Open the Logs tab if the build fails.
  6. 6.Refresh the App tab after the build succeeds.

If you change the model

If you retrain the model and get a new checkpoint, replace best_model.pth with the new file and push again.

This project is already configured to load the checkpoint directly, so no extra training code is needed in the Space.

Runtime settings

  • —MODEL_PATH - Optional local path to the checkpoint inside the Space
  • —HF_MODEL_REPO - Repository to download best_model.pth from when the local file is missing
  • —HF_MODEL_FILENAME - Model filename to download from the Hub. Defaults to best_model.pth

Important note

The checkpoint must contain both model_state_dict and class_to_idx. The training script in this project already saves those keys, so the deployed model must come from that checkpoint format.

Troubleshooting

  • —Authorization error while pushing to Hugging Face usually means the token is missing or stale.
  • —non-fast-forward means the Hugging Face remote has commits your local branch does not have. Pull with rebase first.
  • —No module named src should not happen in the current setup because the Space app no longer depends on a separate src package.
  • —If the app fails to load images or static assets, verify that templates/index.html and static/ are still in the repo.

Suggested file layout

text
hf-space/
├─ app.py
├─ best_model.pth
├─ Dockerfile
├─ README.md
├─ requirements.txt
├─ .dockerignore
├─ .gitattributes
├─ static/
│  ├─ css/
│  │  └─ style-a.css
│  └─ js/
│     └─ app-a.js
└─ templates/
   └─ index.html

Hugging Face Spaces reference

See the official configuration docs at https://huggingface.co/docs/hub/spaces-config-reference