Spaces:
Runtime error
Runtime error
title: Imagebind | |
emoji: 📚 | |
colorFrom: red | |
colorTo: green | |
sdk: docker | |
pinned: false | |
license: mit | |
short_description: Small imagebind api implementation | |
# ImageBind API Implementation | |
A FastAPI implementation of Facebook's ImageBind model for cross-modal embeddings. | |
## Local Setup | |
1. Install system dependencies: | |
```bash | |
sudo apt-get update && sudo apt-get install -y ffmpeg libsndfile1 | |
``` | |
2. Create and activate a virtual environment: | |
```bash | |
python -m venv venv | |
source venv/bin/activate # On Windows: venv\Scripts\activate | |
``` | |
3. Install Python dependencies: | |
```bash | |
pip install --no-cache-dir --upgrade -r requirements.txt | |
``` | |
4. Download and setup ImageBind: | |
```bash | |
python setup_imagebind.py | |
pip install --no-cache-dir . | |
``` | |
## Docker Setup | |
Build and run the container: | |
```bash | |
docker build -t imagebind-api . | |
docker run -p 7860:7860 imagebind-api | |
``` | |
## API Endpoints | |
The API will be available at `http://localhost:7860` with the following endpoints: | |
### POST `/compute_embeddings` | |
Generate embeddings for images, audio files, and text. | |
### POST `/compute_similarities` | |
Compute similarities between embeddings with advanced filtering options: | |
- Threshold filtering for minimum similarity scores | |
- Top-K results limitation | |
- Optional self-similarity inclusion | |
- Score normalization | |
- Detailed match information including original file/text references | |
- Statistical analysis of similarity scores | |
### GET `/health` | |
Basic health check endpoint | |
For detailed API documentation, visit `http://localhost:7860/docs` | |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference | |
## API Authentication | |
The API uses Bearer token authentication. You need to include an authorization header with your API token in all requests: | |
```bash | |
# Set your API token as an environment variable | |
export API_TOKEN="your-api-token-here" | |
# Example curl request with authentication | |
curl -X POST "http://localhost:7860/compute_embeddings" \ | |
-H "Authorization: Bearer ${API_TOKEN}" \ | |
-H "Content-Type: multipart/form-data" \ | |
-F "texts=example text" | |
``` | |
When running the Docker container, you can set the API token as an environment variable: | |
```bash | |
docker run -p 7860:7860 -e API_TOKEN="your-api-token-here" imagebind-api | |
``` | |