Spaces:
Build error
Build error
Commit
·
b564a70
1
Parent(s):
0142aec
app.py
Browse files
app.py
CHANGED
@@ -11,6 +11,17 @@ import gradio as gr
|
|
11 |
# Load the openAI's CLIP model
|
12 |
#model, preprocess = clip.load("ViT-B/32", jit=False)
|
13 |
#display output photo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
def show_output_image(matched_images, photos) :
|
15 |
image=[]
|
16 |
for photo_id in matched_images:
|
@@ -42,16 +53,8 @@ def find_matches(text_features, photo_features, photo_ids, results_count=4):
|
|
42 |
best_photo_idx = (-similarities).argsort()
|
43 |
# Return the photo IDs of the best matches
|
44 |
return [photo_ids[i] for i in best_photo_idx[:results_count]]
|
45 |
-
def image_search(search_text, search_image, option):
|
46 |
-
# taking photo IDs
|
47 |
-
photo_ids = pd.read_csv("./photo_ids.csv")
|
48 |
-
photo_ids = list(photo_ids['photo_id'])
|
49 |
|
50 |
-
|
51 |
-
photos = pd.read_csv("./photos.tsv000", sep="\t", header=0)
|
52 |
-
|
53 |
-
# taking features vectors
|
54 |
-
photo_features = np.load("./features.npy")
|
55 |
|
56 |
# check if CUDA available
|
57 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
|
11 |
# Load the openAI's CLIP model
|
12 |
#model, preprocess = clip.load("ViT-B/32", jit=False)
|
13 |
#display output photo
|
14 |
+
|
15 |
+
# taking photo IDs
|
16 |
+
photo_ids = pd.read_csv("./photo_ids.csv")
|
17 |
+
photo_ids = list(photo_ids['photo_id'])
|
18 |
+
|
19 |
+
# Photo dataset
|
20 |
+
photos = pd.read_csv("./photos.tsv000", sep="\t", header=0)
|
21 |
+
|
22 |
+
# taking features vectors
|
23 |
+
photo_features = np.load("./features.npy")
|
24 |
+
|
25 |
def show_output_image(matched_images, photos) :
|
26 |
image=[]
|
27 |
for photo_id in matched_images:
|
|
|
53 |
best_photo_idx = (-similarities).argsort()
|
54 |
# Return the photo IDs of the best matches
|
55 |
return [photo_ids[i] for i in best_photo_idx[:results_count]]
|
|
|
|
|
|
|
|
|
56 |
|
57 |
+
def image_search(search_text, search_image, option):
|
|
|
|
|
|
|
|
|
58 |
|
59 |
# check if CUDA available
|
60 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|