plantsclassify / README.md
thuonguyenvan
Add plant classification API with Docker support
12ad63a
metadata
title: Plants Classify
emoji: 🌿
colorFrom: green
colorTo: blue
sdk: docker
pinned: false
license: apache-2.0

Plant Classification API 🌿

FastAPI-based REST API for classifying plant images using a ViT-ConvNext hybrid deep learning model.

Features

  • 1139 plant species classification
  • Two prediction endpoints:
    • Upload image file directly
    • Provide image URL
  • Top 5 predictions with confidence scores
  • Fast inference using PyTorch with GPU support

API Endpoints

POST /predict/upload

Upload an image file for classification.

Example:

curl -X POST "https://huggingface.co/spaces/thuonguyenvan/plantsclassify/api/predict/upload" \
  -F "file=@plant_image.jpg"

POST /predict/url

Provide an image URL for classification.

Example:

curl -X POST "https://huggingface.co/spaces/thuonguyenvan/plantsclassify/api/predict/url" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com/plant.jpg"}'

Response Format

{
  "predictions": [
    {
      "class_name": "Oryza_sativa",
      "confidence": 0.8543
    },
    {
      "class_name": "Triticum_aestivum",
      "confidence": 0.0821
    },
    ...
  ]
}

Model Information

  • Architecture: ViT-ConvNext Hybrid (Swin Transformer + ConvNext Tiny)
  • Input: 224x224 RGB images
  • Classes: 1139 plant species
  • Framework: PyTorch + FastAPI

Interactive Documentation

Visit the /docs endpoint for interactive Swagger UI documentation.