Persist Qdrant to host: bind-mount ./data/qdrant; add data dir ignore; update docs
This commit is contained in:
63
USAGE.md
63
USAGE.md
@@ -24,6 +24,20 @@ This document explains how to run and use the Skinbase Vision Stack (Gateway + C
|
||||
|
||||
## Start the stack
|
||||
|
||||
Before starting the stack, create a `.env` file for runtime secrets and environment overrides.
|
||||
|
||||
Minimum example:
|
||||
|
||||
```bash
|
||||
API_KEY=your_api_key_here
|
||||
HUGGINGFACE_TOKEN=your_huggingface_token_here
|
||||
```
|
||||
|
||||
Notes:
|
||||
- `API_KEY` protects gateway endpoints.
|
||||
- `HUGGINGFACE_TOKEN` is required if the configured BLIP model requires Hugging Face authentication.
|
||||
- Startup uses container healthchecks, so initial boot can take longer while models download and warm up.
|
||||
|
||||
Run from repository root:
|
||||
|
||||
```bash
|
||||
@@ -57,6 +71,7 @@ Analyze an image by URL (gateway aggregates CLIP, BLIP, YOLO):
|
||||
|
||||
```bash
|
||||
curl -X POST https://vision.klevze.net/analyze/all \
|
||||
-H "X-API-Key: <your-api-key>" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"url":"https://files.skinbase.org/img/aa/bb/cc/md.webp","limit":5}'
|
||||
```
|
||||
@@ -65,6 +80,7 @@ File upload (multipart):
|
||||
|
||||
```bash
|
||||
curl -X POST https://vision.klevze.net/analyze/all/file \
|
||||
-H "X-API-Key: <your-api-key>" \
|
||||
-F "file=@/path/to/image.webp" \
|
||||
-F "limit=5"
|
||||
```
|
||||
@@ -82,6 +98,7 @@ URL request:
|
||||
|
||||
```bash
|
||||
curl -X POST https://vision.klevze.net/analyze/clip \
|
||||
-H "X-API-Key: <your-api-key>" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"url":"https://files.skinbase.org/img/aa/bb/cc/md.webp","limit":5}'
|
||||
```
|
||||
@@ -90,6 +107,7 @@ File upload:
|
||||
|
||||
```bash
|
||||
curl -X POST https://vision.klevze.net/analyze/clip/file \
|
||||
-H "X-API-Key: <your-api-key>" \
|
||||
-F "file=@/path/to/image.webp" \
|
||||
-F "limit=5"
|
||||
```
|
||||
@@ -102,6 +120,7 @@ URL request:
|
||||
|
||||
```bash
|
||||
curl -X POST https://vision.klevze.net/analyze/blip \
|
||||
-H "X-API-Key: <your-api-key>" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"url":"https://files.skinbase.org/img/aa/bb/cc/md.webp","variants":3}'
|
||||
```
|
||||
@@ -110,6 +129,7 @@ File upload:
|
||||
|
||||
```bash
|
||||
curl -X POST https://vision.klevze.net/analyze/blip/file \
|
||||
-H "X-API-Key: <your-api-key>" \
|
||||
-F "file=@/path/to/image.webp" \
|
||||
-F "variants=3" \
|
||||
-F "max_length=60"
|
||||
@@ -127,6 +147,7 @@ URL request:
|
||||
|
||||
```bash
|
||||
curl -X POST https://vision.klevze.net/analyze/yolo \
|
||||
-H "X-API-Key: <your-api-key>" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"url":"https://files.skinbase.org/img/aa/bb/cc/md.webp","conf":0.25}'
|
||||
```
|
||||
@@ -135,6 +156,7 @@ File upload:
|
||||
|
||||
```bash
|
||||
curl -X POST https://vision.klevze.net/analyze/yolo/file \
|
||||
-H "X-API-Key: <your-api-key>" \
|
||||
-F "file=@/path/to/image.webp" \
|
||||
-F "conf=0.25"
|
||||
```
|
||||
@@ -148,17 +170,20 @@ Return: detected objects with `class`, `confidence`, and `bbox` (bounding box co
|
||||
|
||||
The Qdrant integration lets you store image embeddings and find visually similar images. Embeddings are generated automatically by the CLIP service.
|
||||
|
||||
Qdrant point IDs must be either an unsigned integer or a UUID string. If you send another string value, the wrapper may replace it with a generated UUID and store the original value in metadata as `_original_id`.
|
||||
|
||||
#### Upsert (store) an image by URL
|
||||
|
||||
```bash
|
||||
curl -X POST https://vision.klevze.net/vectors/upsert \
|
||||
-H "X-API-Key: <your-api-key>" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"url":"https://files.skinbase.org/img/aa/bb/cc/md.webp","id":"img-001","metadata":{"category":"wallpaper","source":"upload"}}'
|
||||
-d '{"url":"https://files.skinbase.org/img/aa/bb/cc/md.webp","id":"550e8400-e29b-41d4-a716-446655440000","metadata":{"category":"wallpaper","source":"upload"}}'
|
||||
```
|
||||
|
||||
Parameters:
|
||||
- `url` (required): image URL to embed and store.
|
||||
- `id` (optional): custom string ID for the point; auto-generated if omitted.
|
||||
- `id` (optional): point ID. Use an unsigned integer or UUID string. If omitted, a UUID is auto-generated.
|
||||
- `metadata` (optional): arbitrary key-value payload stored alongside the vector.
|
||||
- `collection` (optional): target collection name (defaults to `images`).
|
||||
|
||||
@@ -166,8 +191,9 @@ Parameters:
|
||||
|
||||
```bash
|
||||
curl -X POST https://vision.klevze.net/vectors/upsert/file \
|
||||
-H "X-API-Key: <your-api-key>" \
|
||||
-F "file=@/path/to/image.webp" \
|
||||
-F 'id=img-002' \
|
||||
-F 'id=550e8400-e29b-41d4-a716-446655440001' \
|
||||
-F 'metadata_json={"category":"photo"}'
|
||||
```
|
||||
|
||||
@@ -175,14 +201,16 @@ curl -X POST https://vision.klevze.net/vectors/upsert/file \
|
||||
|
||||
```bash
|
||||
curl -X POST https://vision.klevze.net/vectors/upsert/vector \
|
||||
-H "X-API-Key: <your-api-key>" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"vector":[0.1,0.2,...],"id":"img-003","metadata":{"custom":"data"}}'
|
||||
-d '{"vector":[0.1,0.2,...],"id":"550e8400-e29b-41d4-a716-446655440002","metadata":{"custom":"data"}}'
|
||||
```
|
||||
|
||||
#### Search similar images by URL
|
||||
|
||||
```bash
|
||||
curl -X POST https://vision.klevze.net/vectors/search \
|
||||
-H "X-API-Key: <your-api-key>" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"url":"https://files.skinbase.org/img/aa/bb/cc/md.webp","limit":5}'
|
||||
```
|
||||
@@ -200,6 +228,7 @@ Return: list of `{"id", "score", "metadata"}` sorted by similarity.
|
||||
|
||||
```bash
|
||||
curl -X POST https://vision.klevze.net/vectors/search/file \
|
||||
-H "X-API-Key: <your-api-key>" \
|
||||
-F "file=@/path/to/image.webp" \
|
||||
-F "limit=5"
|
||||
```
|
||||
@@ -208,6 +237,7 @@ curl -X POST https://vision.klevze.net/vectors/search/file \
|
||||
|
||||
```bash
|
||||
curl -X POST https://vision.klevze.net/vectors/search/vector \
|
||||
-H "X-API-Key: <your-api-key>" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"vector":[0.1,0.2,...],"limit":5}'
|
||||
```
|
||||
@@ -216,44 +246,56 @@ curl -X POST https://vision.klevze.net/vectors/search/vector \
|
||||
|
||||
List all collections:
|
||||
```bash
|
||||
curl https://vision.klevze.net/vectors/collections
|
||||
curl -H "X-API-Key: <your-api-key>" https://vision.klevze.net/vectors/collections
|
||||
```
|
||||
|
||||
Get collection info:
|
||||
```bash
|
||||
curl https://vision.klevze.net/vectors/collections/images
|
||||
curl -H "X-API-Key: <your-api-key>" https://vision.klevze.net/vectors/collections/images
|
||||
```
|
||||
|
||||
Create a custom collection:
|
||||
```bash
|
||||
curl -X POST https://vision.klevze.net/vectors/collections \
|
||||
-H "X-API-Key: <your-api-key>" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"name":"my_collection","vector_dim":512,"distance":"cosine"}'
|
||||
```
|
||||
|
||||
Delete a collection:
|
||||
```bash
|
||||
curl -X DELETE https://vision.klevze.net/vectors/collections/my_collection
|
||||
curl -H "X-API-Key: <your-api-key>" -X DELETE https://vision.klevze.net/vectors/collections/my_collection
|
||||
```
|
||||
|
||||
#### Delete points
|
||||
|
||||
```bash
|
||||
curl -X POST https://vision.klevze.net/vectors/delete \
|
||||
-H "X-API-Key: <your-api-key>" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"ids":["img-001","img-002"]}'
|
||||
-d '{"ids":["550e8400-e29b-41d4-a716-446655440000","550e8400-e29b-41d4-a716-446655440001"]}'
|
||||
```
|
||||
|
||||
#### Get a point by ID
|
||||
|
||||
```bash
|
||||
curl https://vision.klevze.net/vectors/points/img-001
|
||||
curl -H "X-API-Key: <your-api-key>" https://vision.klevze.net/vectors/points/550e8400-e29b-41d4-a716-446655440000
|
||||
```
|
||||
|
||||
#### Get a point by original application ID
|
||||
|
||||
If the wrapper had to replace your string `id` with a generated UUID, the original value is preserved in metadata as `_original_id`.
|
||||
|
||||
```bash
|
||||
curl -H "X-API-Key: <your-api-key>" https://vision.klevze.net/vectors/points/by-original-id/img-001
|
||||
```
|
||||
|
||||
## Request/Response notes
|
||||
|
||||
- For URL requests use `Content-Type: application/json`.
|
||||
- For uploads use `multipart/form-data` with a `file` field.
|
||||
- Most gateway endpoints require the `X-API-Key` header.
|
||||
- Remote image URLs must resolve to public hosts and return an image content type.
|
||||
- The gateway aggregates and normalizes outputs for `/analyze/all`.
|
||||
|
||||
## Running a single service
|
||||
@@ -281,6 +323,9 @@ uvicorn main:app --host 0.0.0.0 --port 8000
|
||||
## Troubleshooting
|
||||
|
||||
- Service fails to start: check `docker compose logs <service>` for model load errors.
|
||||
- BLIP startup error about Hugging Face auth: set `HUGGINGFACE_TOKEN` in `.env` and rebuild `blip`.
|
||||
- Qdrant upsert error about invalid point ID: use a UUID or unsigned integer for `id`, or omit it and use the returned generated `id`.
|
||||
- Image URL rejected before download: the URL may point to localhost, a private IP, a non-`http/https` scheme, or a non-image content type.
|
||||
- High memory / OOM: increase host memory or reduce model footprint; consider GPUs.
|
||||
- Slow startup: model weights load on service startup — expect extra time.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user