A blazing-fast inference server for computer vision tasks using FastAPI, YOLO, DINOv2, and FAISS! 🚀
- YOLOv8 Segmentation: Detect and segment objects in images
- DINOv2 Embeddings: Extract powerful image features
- FAISS Vector Search: Find similar items using vector search
- Easy REST API: Simple endpoints for integration with any frontend
git clone <your-repo-url>
cd <your-project-directory>pip install -r requirements.txt- Place your YOLO model at
models/deepfashion2_yolov8s-seg.pt - Place your FAISS index and metadata at
index/jersey_index.faissandindex/jersey_metadata.npy
uvicorn inference_server:app --host 0.0.0.0 --port 8000 --reload- Description: Run YOLOv8 segmentation on an image
- Request: Multipart/form-data with an image file
- Response: JSON with detected polygons
- Description: Extract DINOv2 features from an image
- Request: Multipart/form-data with an image file
- Response: JSON with feature vector
- Description: Search for similar items using FAISS
- Request: JSON with
features(list of floats) - Response: JSON with ranked search results
import requests
with open('your_image.jpg', 'rb') as f:
response = requests.post('http://localhost:8000/yolo', files={'file': f})
print(response.json())import requests
with open('your_image.jpg', 'rb') as f:
response = requests.post('http://localhost:8000/dino', files={'file': f})
print(response.json())import requests
features = [0.1, 0.2, ...] # Replace with your feature vector
response = requests.post('http://localhost:8000/faiss', json={'features': features})
print(response.json())If using a frontend on a different port, make sure to enable CORS in inference_server.py:
from fastapi.middleware.cors import CORSMiddleware
app.add_middleware(
CORSMiddleware,
allow_origins=["https://localhost:8081"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)├── inference_server.py # FastAPI app and endpoints
├── requirements.txt # Python dependencies
├── models/
│ └── deepfashion2_yolov8s-seg.pt
├── index/
│ ├── jersey_index.faiss
│ └── jersey_metadata.npy
MIT License