CoolFace
Apppublic

ioget/aims-cv-app

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

Intel Image Classifier — Flask App

Classifies images into 6 categories: buildings, forest, glacier, mountain, sea, street using two pre-trained models — PyTorch (.pth) and Keras/TensorFlow (.keras).


Project structure

App-project/
├── rosly_mamekem_model.pth       ← original model files (kept here as backup)
├── rosly_mamekem_model.keras
└── flask_app/
    ├── app.py                    ← Flask server (inference + routes)
    ├── requirements.txt
    ├── Procfile                  ← for Render / Railway
    ├── README.md
    ├── models/
    │   ├── rosly_mamekem_model.pth
    │   └── rosly_mamekem_model.keras
    └── templates/
        └── index.html            ← full frontend (HTML + Tailwind + JS)

Run locally

1. Create a virtual environment

bash
cd flask_app
python3 -m venv venv

2. Activate it

bash
# Linux / Mac
source venv/bin/activate

# Windows
venv\Scripts\activate

3. Install dependencies

bash
pip install -r requirements.txt
PyTorch only (lighter): if you don't need TensorFlow, this is enough. TensorFlow is optional — the app still works with just PyTorch.

4. Run

bash
python app.py

Open http://localhost:5000 in your browser.

Enable auto-reload during development

bash
FLASK_DEBUG=true python app.py

Deploy on Hugging Face Spaces (Docker)

Hugging Face Spaces is great for ML school projects — free, public URL, no credit card.

Steps

  1. 1.Go to huggingface.co/spaces and click Create new Space.
  1. 1.Fill in:
FieldValue
Space nameintel-image-classifier (or any name)
SDKDocker
VisibilityPublic
  1. 1.Clone the Space repo locally:
bash
   git clone https://huggingface.co/spaces/YOUR_USERNAME/intel-image-classifier
   cd intel-image-classifier
  1. 1.Copy the contents of flask_app/ into the cloned repo:
bash
   cp -r /path/to/flask_app/* .
  1. 1.Push everything:
bash
   git add .
   git commit -m "deploy flask app"
   git push
  1. 1.Hugging Face reads the Dockerfile automatically and builds the image. Your app will be live at: https://YOUR_USERNAME-intel-image-classifier.hf.space
The free tier may take 30-60 seconds to start on the first request (cold start). If the Space sleeps, just refresh the page and wait.

Deploy on Render (free — recommended for school)

  1. 1.Push your project to a GitHub repo (include the models/ folder).
  1. 1.Go to render.com → New → Web Service.
  1. 1.Connect your repo and fill in:
FieldValue
Root Directoryflask_app
RuntimePython 3
Build Commandpip install -r requirements.txt
Start Commandgunicorn app:app
  1. 1.Click Deploy → you get a public URL like https://your-app.onrender.com.
The free tier sleeps after 15 min of inactivity. First request after sleep takes ~30 s. Fine for a school demo.

Deploy on Railway (alternative)

  1. 1.Go to railway.app → New Project → Deploy from GitHub.
  2. 2.Select your repo, set Root Directory to flask_app.
  3. 3.Railway reads the Procfile automatically. Done.

Notes

  • —TensorFlow is a large package (~500 MB). If you only need PyTorch, remove tensorflow from requirements.txt.
  • —The app handles the case where a model is not installed — it returns a clear error message instead of crashing.
  • —Models are trained on 64×64 images with 6 classes.

Environment variables

VariableDefaultDescription
PORT5000Port (set automatically by Render/Railway)
FLASK_DEBUGfalseSet to true for auto-reload during dev

AIMS-Computer-vision-app