Dockerize-Model is an end-to-end, Docker-ready deep learning project that classifies fresh vs. rotten fruits (peaches, pomegranates, strawberries). The repository includes data processing utilities, model training code, a FastAPI inference service, and Docker configuration for reproducible deployment.
- Features
- Quick Start
- Local Development
- Docker Deployment
- API Reference (examples)
- Configuration
- Project Structure
- Notes: Model & Data
- Contributing
- License
- Image classification for multiple fruit types (fresh/rotten)
- Modular and well-organized code (data, models, api, utils)
- FastAPI REST service for inference
- Dockerfile for consistent deployment
- Logging and configuration via
src/constants/constants.py
- Build the Docker image:
docker build -t dockerize-model .- Run the container and expose the API:
docker run -it -p 5000:5000 dockerize-model- Visit the interactive API docs: http://localhost:5000/docs
- Create and activate a virtual environment (recommended):
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt- Run the FastAPI app locally:
python src/api/main.py- Open the API docs: http://localhost:5000/docs
Predict endpoint:
- POST /predict
- Accepts: multipart/form-data with a file field named
file - Returns: JSON with
FileName,PredictionClass, andprediction(confidence)
- Accepts: multipart/form-data with a file field named
Example curl request:
curl -X POST "http://localhost:5000/predict" -F "file=@/path/to/image.jpg"Example Python client (requests):
import requests
url = "http://localhost:5000/predict"
with open("/path/to/image.jpg", "rb") as f:
r = requests.post(url, files={"file": f})
print(r.json())Sample response:
{
"FileName": "strawberry.jpg",
"PredictionClass": "Fresh Strawberries",
"prediction": 0.9876
}- Most runtime/configuration values live in
src/constants/constants.py(e.g.,MODEL_PATH,HOST,PORT, andRESIZE). - Make sure the model file is available at
models/checkpoints/model.kerasor updateMODEL_PATH.
Note: The README previously referenced
src/constant/constant.py. The correct path issrc/constants/constants.py.
Dockerize-Model
├── Dockerfile
├── README.md
├── requirements.txt
├── src/
│ ├── api/ # FastAPI app, endpoints and schemas
│ ├── constants/ # Paths and configuration
│ ├── data/ # Data ingestion/processing helpers
│ ├── models/ # Model definition / training utilities
│ └── utils/ # Helpers (e.g., model loading)
├── data/
│ ├── raw/
│ └── processed/
├── models/
│ └── checkpoints/ # Place `model.keras` here
├── notebooks/ # EDA and experiments
└── logs/
- Pretrained model:
models/checkpoints/model.keras(expected by default). If not present, inference will fail when loading the model — see logs for details. - Data files used for experiments are in
data/processed/*.json(train/test splits).
- If server fails to start, check
MODEL_PATHand ensure the model file exists. - Validate image uploads via the
/docsUI to see expected request shape. - Logs are written to the
logs/directory (seeLOG_FILEandLOG_DIRinsrc/constants/constants.py).
Contributions, bug reports, and improvements are welcome. Please open an issue or submit a pull request.
This project is licensed under the MIT License — see the LICENSE file.