This project leverages PyTorch and OpenAI CLIP for advanced text-based semantic image search capabilities. The backend is built using FastAPI, ensuring a robust and high-performance server, while the frontend is developed with Next.js, providing a seamless and responsive user experience.
- Text-based semantic image search using OpenAI CLIP
- Frontend built with React (Next.js) and styled with Tailwind CSS
- Backend built with FastAPI and powered by PyTorch
- Preloaded random images for demonstration purposes
- Backend: FastAPI, PyTorch, Hugging Face Transformers
- Frontend: Next.js, Tailwind CSS, React
- Other: Node.js, Python, OpenAI CLIP
Before running the project, make sure you have the following installed:
- Python 3.10+: Download
- Node.js: Download
- Unsplash Developer Access Key (optional, for fetching new random images): Get Access Key
git clone https://github.com/your-username/your-repo.git
cd your-repo
- Navigate to the
backend
directory:cd backend
- Create a virtual environment:
python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
- Start the FastAPI server:
By default, the server will run at
uvicorn call:app --reload
http://127.0.0.1:8000
.
- Navigate to the frontend directory:
cd frontend/semantic-image-search
- Install dependencies:
npm install
- Start the development server:
The frontend will be available at
npm run dev
http://localhost:3000
.
If you’d like to use different images for the project:
- Replace the images in the
random-images
folder:- Use the provided script to fetch random images from Unsplash:
Note: You need an Unsplash Developer Access Key to use the script. Add it to the script by replacing the placeholder
python backend/get-random-images.py
ACCESS_KEY
with your access key.
- Use the provided script to fetch random images from Unsplash:
- Alternatively, manually replace the images in the
random-images
folder with your own collection.
- Open the frontend in your browser:
http://localhost:3000
. - Search for images using text queries such as "beautiful sunset," "expansive ocean," or "snowy mountains."
- Results will display a set of images matching the query from the preloaded random dataset.