Sign inSign up

atakanemree/image-caption-api

By atakanemree

•Updated 10 months ago

Production-ready Image Captioning API powered by PyTorch & FastAPI.

Image
Machine learning & AI
0

251

atakanemree/image-caption-api repository overview

⁠🖼️ Image Captioning API

Docker Pulls License GitHub

Production-ready Image Captioning Service powered by PyTorch and FastAPI. Generate human-like captions for images with a single API call.

⁠🚀 Quick Start

The easiest way to run the API is using Docker:

docker run -p 8000:8000 atakanemree/image-caption-api:latest

Once running, access the API documentation at: http://localhost:8000/docs⁠

⁠✨ Features

  • 🧠 Advanced Architecture: ResNet50 Encoder + LSTM Decoder with Attention
  • ⚡ High Performance: Optimized for speed (~50ms inference on CPU)
  • 🐳 Docker Ready: Pre-built images for CPU and GPU
  • 🔍 Beam Search: High-quality caption generation
  • 🛡️ Robust: Input validation, error handling, and health checks

⁠🎯 Usage

⁠1. Health Check
curl http://localhost:8000/health
⁠2. Generate Caption
curl -X POST \
  http://localhost:8000/predict \
  -H 'Content-Type: multipart/form-data' \
  -F '[email protected]'

Response:

{
    "predicted_caption": "a dog running on the grass",
    "confidence": 0.85,
    "timestamp": "2023-11-29T12:00:00"
}
⁠3. Batch Prediction
curl -X POST \
  http://localhost:8000/predict/batch \
  -H 'Content-Type: multipart/form-data' \
  -F '[email protected]' \
  -F '[email protected]'

⁠🐳 Docker Variants

TagDescriptionSizeUse Case
latest / latest-cpuCPU optimized version~800MBGeneral purpose, low cost deployment
latest-gpuGPU enabled (CUDA 11.8)~2.5GBHigh throughput, training
⁠Running with GPU
docker run --gpus all -p 8000:8000 atakanemree/image-caption-api:latest-gpu

⁠🔧 Configuration

You can configure the container using environment variables:

docker run -p 8000:8000 \
  -e API_WORKERS=4 \
  -e LOG_LEVEL=INFO \
  atakanemree/image-caption-api:latest

⁠🏗️ Architecture

The system consists of a ResNet50 CNN for image feature extraction and an LSTM RNN for text generation. The API is built with FastAPI for high performance and easy integration.

For more details, source code, and training instructions, visit the GitHub Repository⁠.

Tag summary

Content type

Image

Digest

sha256:b27193346…

Size

312.6 MB

Last updated

10 months ago

docker pull atakanemree/image-caption-api