File size: 2,292 Bytes
5f1fdf7 64e55d6 6284a4a 64e55d6 6284a4a 64e55d6 63b0848 64e55d6 6284a4a 64e55d6 5f1fdf7 6284a4a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
---
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
```
|