An intelligent image search application that uses AI-powered embeddings to find images. Upload images and search through your collection using natural language descriptions or by uploading reference images.
This project combines a modern Next.js frontend with a FastAPI backend powered by OpenAI's CLIP model for semantic image search. The application allows users to:
- Upload images to build a searchable collection
- Search for images using text descriptions
- View results in a clean, responsive grid layout
Image.Search.-.Google.Chrome.2025-07-08.21-04-35.mp4
- Frontend: Next.js 15 with React 19, TailwindCSS, and TypeScript
- Backend: FastAPI with CLIP (Contrastive Language-Image Pre-Training) model
- AI Model: OpenAI CLIP for generating image embeddings and semantic search
- Storage: Local file system for images and pickle files for embeddings
This is the easiest way to get the project running. Docker will handle all dependencies and setup for you.
-
Build and run with Docker Compose
docker-compose build
docker-compose up
OR use the convenient npm script:
npm run docker:up
β οΈ Note: The initial build can take a while (10-15 minutes) as it needs to download PyTorch, CLIP model, and install all dependencies. Subsequent runs will be much faster thanks to Docker layer caching. -
Access the application
- Frontend: http://localhost:3000
- Backend API: http://localhost:8000
-
Stop the application
docker-compose down
OR use the npm script:
npm run docker:down
If you prefer to run the project locally without Docker:
- Python 3.8+ with pip
- Node.js 18+ with npm
- Git
From the root of the project, you can use:
- Install all dependencies
npm install- Run with one of the methods
npm run build # Build everything (backend and frontend)npm run start # Start production serversOR For development mode (hot reload, etc.):
npm run dev # Start both backend and frontend in development mode-
Install Python dependencies
pip install -r .\apps\python-backend\requirements.txt
-
Run the Python backend
py .\apps\python-backend\main.py
The backend will be available at http://localhost:8000
-
Install Node.js dependencies
npm install
-
Run the frontend in development mode
cd .\apps\web\ npm install npm run dev
The frontend will be available at http://localhost:3000
If you want to run the optimized production build:
-
Build the frontend
cd .\apps\web\ npm run build
OR build everything from the root:
npm run build
-
Start the production server
npm run start
Image-Search/
βββ apps/
β βββ python-backend/ # FastAPI backend
β β βββ main.py # API server
β β βββ Model_Backend.py # CLIP model integration
β β βββ requirements.txt # Python dependencies
β β βββ embeddings/ # Stored image embeddings
β β βββ images/ # Uploaded images
β βββ web/ # Next.js frontend
β βββ src/app/ # App router pages
β βββ src/components/ # React components
β βββ package.json # Frontend dependencies
βββ docker-compose.yml # Docker configuration
βββ package.json # Root package.json with scripts
βββ README.md # This file
POST /upload_imageβ Upload a new image fileGET /add_image/{image_path}β Add an image from the server's image directory to the search indexGET /search_images/{query}β Search images by text description (with optionalmin_score)GET /list_imagesβ List all uploaded image filenames (sorted by date added)GET /images/{filename}β Serve an uploaded image fileGET /healthβ Health check endpoint (returns backend status)
For a scalable, robust production deployment, consider the following improvements:
-
Use a Vector Database or Azure AI Search for Embeddings
- Instead of storing image embeddings locally (e.g., in pickle files), use a dedicated vector database such as Pinecone, Weaviate, Qdrant, or Milvus. These databases are optimized for fast, large-scale similarity search and can handle millions of vectors efficiently.
- Alternatively, you can use Azure AI Search service, which supports vector search and integrates well with other Azure services.
- This approach enables much faster and more scalable search for large image collections.
-
Serve Images from a Dedicated Storage Service
- Instead of serving images from the local file system, upload and store images in a cloud storage service such as Azure Blob Storage, AWS S3, or Google Cloud Storage.
- Serve images directly from the storage service using secure URLs or CDN endpoints for better performance, reliability, and scalability.
- This also simplifies backup, access control, and integration with other cloud services.
By following these recommendations, you can scale your image search application to handle production workloads and large datasets efficiently.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
-
Docker build takes too long: This is normal for the first build. The CLIP model and PyTorch are large downloads.
-
Port conflicts: If ports 3000 or 8000 are already in use, modify the ports in
docker-compose.yml -
Python dependencies issues: Make sure you're using Python 3.8+ and have pip updated to the latest version.
-
CORS errors: The backend is configured to allow all origins. If you're still getting CORS errors, check that both servers are running.
If you encounter any issues:
- Check the Docker/application logs
- Ensure all prerequisites are installed
- Try the Docker approach if local development isn't working