Logo Lanfrica

cicerothoma/naija-food-classifier-server

Domain:

agriculture

Record type:

softwaremodel
Creator:
cic
Host:
# Naija Food Classification Server A Flask-based REST API for classifying Nigerian food dishes using PyTorch image classification. ## Features - **Image Classification**: Identifies 18 different Nigerian food dishes - **Multiple Input Formats**: Supports both file upload and base64 encoded images - **Top-3 Predictions**: Returns the top 3 most likely food classes with confidence scores - **CORS Enabled**: Ready for frontend integration - **Health Check**: Monitor server status and model loading ## Supported Food Classes The model can identify the following Nigerian dishes: - Jollof Rice - Egusi Soup - Moi Moi - Akara - Suya - Efo Riro - Okra Soup - Ofada Rice - Pounded Yam - Banga Soup - Pepper Soup - Nkwobi - Amala - Ewedu Soup - Ogbono Soup - Yam Porridge - Puff Puff - Chin Chin ## Installation 1. **Install Dependencies**: ```bash pip install -r requirements.txt ``` 2. **Ensure Model File**: Make sure your trained PyTorch model file `best.pt` is in the project root directory. 3. **Run the Server**: ```bash python app.py ``` The server will start on `localhost` ## API Endpoints ### 1. Health Check **GET** `/` Returns server status and model information. ```bash curl localhost ``` **Response:** ```json { "status": "healthy", "message": "Naija Food Classification API is running!", "model_loaded": true, "classes_loaded": true, "total_classes": 18 } ``` ### 2. Get Food Classes **GET** `/classes` Returns the list of all supported food classes. ```bash curl localhost ``` **Response:** ```json { "classes": ["Jollof Rice", "Egusi Soup", "Moi Moi", ...], "total_classes": 18 } ``` ### 3. Predict from Image File **POST** `/predict` Upload an image file for classification. ```bash curl -X POST -F "image=@path/to/your/image.jpg" localhost ``` **Response:** ```json { "success": true, "predictions": [ { "class": "Jollof Rice", "confidence": 0.89, "percentage": "89.00%" }, { "class": "Ofada Ric …