Vela
commited on
Commit
Β·
5427e5e
1
Parent(s):
03d6ad4
Started adding api's
Browse files- README.md +61 -1
- src/api/__pycache__/main.cpython-313.pyc +0 -0
- src/api/main.py +7 -0
- src/api/routes/__init__.py +1 -0
- src/api/routes/__pycache__/__init__.cpython-313.pyc +0 -0
- src/api/routes/__pycache__/home_page_api.cpython-313.pyc +0 -0
- src/api/routes/home_page_api.py +16 -0
- src/api/schemas/__pycache__/schema.cpython-313.pyc +0 -0
- src/api/schemas/schema.py +5 -0
- src/app/app.py +1 -2
- src/app/request_app.py +6 -0
- src/data/request_images.py +1 -1
README.md
CHANGED
@@ -9,4 +9,64 @@ app_file: src/app/app.py
|
|
9 |
pinned: false
|
10 |
---
|
11 |
|
12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
pinned: false
|
10 |
---
|
11 |
|
12 |
+
<!-- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
13 |
+
|
14 |
+
π Project Overview
|
15 |
+
|
16 |
+
Look-A-Like Image Finder is an AI-powered image search tool that allows users to find visually similar images based on an input image or a text query. It utilizes Pinecone for vector search, OpenAI CLIP for embeddings, and Streamlit for an intuitive user interface.
|
17 |
+
|
18 |
+
β¨ Features
|
19 |
+
π Image Search β Find images similar to a given input.
|
20 |
+
π Text-to-Image Search β Retrieve images using natural language descriptions.
|
21 |
+
π Efficient Indexing β Uses Pinecone to store and retrieve image embeddings.
|
22 |
+
|
23 |
+
π Tech Stack
|
24 |
+
πΌ Model β OpenAI CLIP (Contrastive Language-Image Pretraining)
|
25 |
+
π Vector Search β Pinecone (Efficient indexing and retrieval)
|
26 |
+
π₯ Frontend β Streamlit (Interactive web UI)
|
27 |
+
π Backend β Python
|
28 |
+
β Deployment β Hugging Face Spaces
|
29 |
+
|
30 |
+
π₯ Resources
|
31 |
+
π Download the Dataset : {https://unsplash.com/data/lite/latest}
|
32 |
+
π Pinecone API Key Setup : {https://www.pinecone.io/} -->
|
33 |
+
|
34 |
+
<!-- π How to Run the Application Locally -->
|
35 |
+
|
36 |
+
<!-- Step 1: Clone the Repository -->
|
37 |
+
<!-- Copy and paste the following command into your terminal -->
|
38 |
+
<!-- git clone https://github.com/Vela-Test1993/lookalike-image-finder.git -->
|
39 |
+
<!-- cd lookalike-image-finder -->
|
40 |
+
|
41 |
+
<!-- Step 2: Install Dependencies -->
|
42 |
+
<!-- Run the following command to install the required packages -->
|
43 |
+
<!-- pip install -r requirements.txt -->
|
44 |
+
|
45 |
+
<!-- Step 3: Start the Application -->
|
46 |
+
<!-- Use the command below to launch the app -->
|
47 |
+
<!-- streamlit run src/app/app.py -->
|
48 |
+
|
49 |
+
<!-- Step 4: Open in Your Browser -->
|
50 |
+
<!-- The application will automatically open in your default web browser. -->
|
51 |
+
|
52 |
+
<!-- β Important: API Key Setup -->
|
53 |
+
<!-- Create a .env file in the project's root directory and store your Pinecone API key inside it. -->
|
54 |
+
|
55 |
+
|
56 |
+
<!-- π Setting Up the Application Components -->
|
57 |
+
|
58 |
+
<!-- π’ Pinecone: Vector Database -->
|
59 |
+
<!-- 1οΈβ£ Log in to your Pinecone account. -->
|
60 |
+
<!-- 2οΈβ£ Retrieve your Pinecone API key. -->
|
61 |
+
<!-- 3οΈβ£ Store the API key securely in the .env file. -->
|
62 |
+
|
63 |
+
<!-- π Dataset: Image Processing -->
|
64 |
+
<!-- 1οΈβ£ Download the dataset from the following link: https://unsplash.com/data/lite/latest -->
|
65 |
+
<!-- 2οΈβ£ Convert the images into vector embeddings using OpenAI CLIP. -->
|
66 |
+
<!-- 3οΈβ£ Store the embeddings in Pinecone for efficient retrieval. -->
|
67 |
+
|
68 |
+
<!-- π¨ Streamlit: Web Interface -->
|
69 |
+
<!-- 1οΈβ£ Streamlit is used to build the user-friendly UI/UX for the application. -->
|
70 |
+
<!-- 2οΈβ£ The frontend allows users to search for similar images using image or text queries. -->
|
71 |
+
<!-- 3οΈβ£ The interface is interactive and easy to navigate. -->
|
72 |
+
|
src/api/__pycache__/main.cpython-313.pyc
ADDED
Binary file (403 Bytes). View file
|
|
src/api/main.py
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastapi import FastAPI, HTTPException
|
2 |
+
from routes import homepage_router
|
3 |
+
|
4 |
+
app = FastAPI()
|
5 |
+
|
6 |
+
# Include the routers in the app
|
7 |
+
app.include_router(homepage_router, prefix="/api", tags=["Home Page"])
|
src/api/routes/__init__.py
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
from .home_page_api import router as homepage_router
|
src/api/routes/__pycache__/__init__.cpython-313.pyc
ADDED
Binary file (229 Bytes). View file
|
|
src/api/routes/__pycache__/home_page_api.cpython-313.pyc
ADDED
Binary file (1.15 kB). View file
|
|
src/api/routes/home_page_api.py
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import sys
|
3 |
+
src_directory = os.path.abspath(os.path.join(os.path.dirname(__file__), "../../..", "src"))
|
4 |
+
sys.path.append(src_directory)
|
5 |
+
from fastapi import APIRouter, HTTPException
|
6 |
+
from schemas import schema
|
7 |
+
from app import homepage
|
8 |
+
|
9 |
+
|
10 |
+
router = APIRouter()
|
11 |
+
|
12 |
+
@router.post("/{text_querry}", summary="Find the image by text")
|
13 |
+
def search_image(search_image: schema.ImageSearch):
|
14 |
+
homepage.get_images_by_text(search_image.querry_text)
|
15 |
+
|
16 |
+
|
src/api/schemas/__pycache__/schema.cpython-313.pyc
ADDED
Binary file (497 Bytes). View file
|
|
src/api/schemas/schema.py
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from pydantic import BaseModel
|
2 |
+
|
3 |
+
class ImageSearch(BaseModel):
|
4 |
+
querry_text : str
|
5 |
+
|
src/app/app.py
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
import homepage
|
2 |
import torch
|
3 |
-
import streamlit as st
|
4 |
|
5 |
homepage.setup_page()
|
6 |
homepage.search_tab()
|
7 |
-
st.link_button("Navigate to load data page",url="http://localhost:8501/load_data_page")
|
|
|
1 |
import homepage
|
2 |
import torch
|
|
|
3 |
|
4 |
homepage.setup_page()
|
5 |
homepage.search_tab()
|
6 |
+
# st.link_button("Navigate to load data page",url="http://localhost:8501/load_data_page")
|
src/app/request_app.py
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import requests
|
2 |
+
|
3 |
+
def get_api(end_point : str = None):
|
4 |
+
# r = requests.get(f"https://velatest-world-data-insights-api.hf.space/{end_point}")
|
5 |
+
r = requests.get(f"http://127.0.0.1:8000/{end_point}")
|
6 |
+
return r.json()
|
src/data/request_images.py
CHANGED
@@ -21,4 +21,4 @@ def convert_image_to_embedding_format(query_image):
|
|
21 |
logger.info("Loaded the image to embed successfully")
|
22 |
return image
|
23 |
except Exception as e:
|
24 |
-
logger.error(f"Unable to load the image to embed {e}")
|
|
|
21 |
logger.info("Loaded the image to embed successfully")
|
22 |
return image
|
23 |
except Exception as e:
|
24 |
+
logger.error(f"Unable to load the image to embed {e}")
|