Gemstone Classifier API

A RESTful API for classifying gemstone images using a pre-trained deep learning model.

Features

  • Image classification for 85 different types of gemstones
  • High accuracy prediction with confidence scores
  • RESTful API with proper error handling
  • Swagger UI documentation
  • Containerized deployment with Docker

API Endpoints

The API is versioned with a prefix: /api/v1

Root Endpoint

GET /

Returns basic information about the API and available endpoints.

Health Check

GET /api/v1/health

Checks if the API is running and the model is loaded.

List Gemstone Classes

GET /api/v1/classes

Returns a list of all gemstone classes that the model can predict.

Predict Gemstone

POST /api/v1/predict

Predicts the gemstone class from an uploaded image.

Request:

  • Content-Type: multipart/form-data
  • Body: file (image file)

Response:

{
  "prediction": "Ruby",
  "confidence": 0.98,
  "timestamp": "2023-04-01T12:34:56.789Z"
}

API Documentation

The API documentation is available at /docs when the server is running.

Installation and Setup

Prerequisites

  • Python 3.10 or higher
  • TensorFlow 2.15.0
  • FastAPI 0.109.0

Local Development

  1. Clone the repository
  2. Install dependencies:
    pip install -r requirements.txt
    
  3. Run the server:
    uvicorn app:app --reload
    
  4. Access the API at http://localhost:8000
  5. Access the API documentation at http://localhost:8000/docs

Docker Deployment

  1. Build the Docker image:
    docker build -t gemstone-classifier-api .
    
  2. Run the container:
    docker run -p 7860:7860 gemstone-classifier-api
    
  3. Access the API at http://localhost:7860
  4. Access the API documentation at http://localhost:7860/docs

Environment Variables

The following environment variables can be set to configure the API:

  • MODEL_PATH: Path to the model file (default: gemstone_classifier.h5)
  • CLASS_NAMES_PATH: Path to the class names file (default: class_names.csv)

Model Information

The model is a convolutional neural network trained on a dataset of gemstone images. It can classify 85 different types of gemstones with high accuracy.

Input image requirements:

  • The model expects images to be resized to 150x150 pixels
  • Images can be in any common format (JPEG, PNG, etc.)
  • Images should be clear and well-lit for best results

License

This project is licensed under the MIT License - see the LICENSE file for details.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support