A FastAPI-based service that leverages the Florence-2 model for advanced image and text processing. This project provides a containerized API service that can be easily deployed using Docker.
- FastAPI-based REST API
- Florence-2 model integration
- GPU acceleration support
- Containerized deployment
- Environment variable configuration
- Docker
- NVIDIA GPU with CUDA support
- NVIDIA Container Toolkit installed
florence_api/
├── app/ # Application code
├── model/ # Florence model files
├── docker/ # Docker configuration
│ ├── Dockerfile
│ └── docker-compose.yml
├── main.py # FastAPI application entry point
├── requirements.txt # Python dependencies
└── .env # Environment variables
Create a .env file in the root directory with the following variables:
API_HOST=0.0.0.0
API_PORT=8000
MODEL_PATH=/app/model-
Build the Docker image
cd docker docker compose build --no-cache -
Start the service
docker compose up
The API will be available at
http://localhost:8000 -
Stop the service
docker compose down
Once the service is running, you can access:
- API documentation:
http://localhost:8000/docs - Alternative documentation:
http://localhost:8000/redoc
Make sure your NVIDIA driver supports the CUDA version specified in the Dockerfile. You can check your supported CUDA version with:
nvidia-smiEnsure the NVIDIA Container Toolkit is properly installed:
nvidia-container-cli info[Your License Here]
[Your Contributing Guidelines Here]