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.
- Classify images with Torchvision models:
resnet18,alexnet,vgg16, andinception_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.
.
|-- 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
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.txtPrepare the image resources:
python app/prepare_images.pyOptional: pre-download the model weights before starting the server:
python app/prepare_models.pyStart the FastAPI server:
uvicorn main:app --reloadOpen http://127.0.0.1:8000.
| 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 |
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 8001The 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
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/.