Skip to content

EYA179/VisionLab-Image-Classification-Server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

VisionLab Image Classification Server

VisionLab is a FastAPI web application for image classification experiments. It serves a small browser interface where users can classify ImageNet sample images, upload their own images, apply basic image transformations, compute grayscale histograms, and download classification results as JSON or PNG plots.

Features

  • Classify images with Torchvision models: resnet18, alexnet, vgg16, and inception_v3.
  • Download and prepare 1,000 ImageNet sample images plus ImageNet labels.
  • Show top-5 classification scores in the browser with Chart.js.
  • Upload a local image and classify it without saving the uploaded file on disk.
  • Adjust image color, brightness, contrast, and sharpness before classification.
  • Compute grayscale image histograms with OpenCV and NumPy.
  • Download classification output as JSON or as a generated PNG plot.

Project Structure

.
|-- app/
|   |-- config.py                 # Model list and image resource path
|   |-- prepare_images.py         # Downloads sample images and labels
|   |-- prepare_models.py         # Pre-downloads Torchvision model weights
|   |-- ml/                       # Classification helpers
|   |-- histogram/                # Histogram helpers
|   |-- transformations/          # PIL image transformation helpers
|   |-- forms/                    # Form parsing classes
|   |-- static/                   # Frontend JavaScript and favicon
|   `-- templates/                # Jinja templates
|-- showcase/                     # Static public-facing project overview
|-- main.py                       # FastAPI routes
|-- requirements.txt
`-- Documentation.md              # Original issue implementation notes

Setup

Create and activate a Python environment:

python3 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -r requirements.txt

Prepare the image resources:

python app/prepare_images.py

Optional: pre-download the model weights before starting the server:

python app/prepare_models.py

Run

Start the FastAPI server:

uvicorn main:app --reload

Open http://127.0.0.1:8000.

Main Routes

Route Purpose
/ Home page
/info JSON list of configured models and prepared sample images
/classifications Select a prepared image and classify it
/classify_transform Transform a prepared image before classification
/histograms Compute a grayscale histogram for a prepared image
/uploadImage Upload and classify a local image
/outputJSON Download classification scores as JSON
/outputPNG Download classification scores as a PNG plot

Verification

The app was verified locally with:

python app/prepare_images.py
python -c "import main; print(len(main.app.routes))"
uvicorn main:app --host 127.0.0.1 --port 8001

The following checks returned 200 OK:

GET  /
GET  /info
GET  /classifications
GET  /classify_transform
GET  /histograms
GET  /uploadImage
GET  /docs
POST /histograms
POST /classifications
POST /classify_transform
POST /classifyUpload
GET  /outputJSON
GET  /outputPNG

Showcase Page

The showcase/ folder contains a static project overview page for portfolio or Vercel deployment. If deploying only the showcase on Vercel, set the root directory to showcase/.

About

FastAPI image classification server with Torchvision models, image upload, transformations, histograms, and downloadable results.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors