Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -36,7 +36,7 @@ embeddings = emb_df.drop(columns=["image_id"]).values.astype(np.float32)
|
|
| 36 |
sampled_indices = np.load("sampled_indices_3000.npy").astype(int).tolist()
|
| 37 |
|
| 38 |
# Load dataset and select the sampled subset
|
| 39 |
-
ds = load_dataset("JamieSJS/stanford-online-products", "corpus"
|
| 40 |
sampled_dataset = ds.select(sampled_indices)
|
| 41 |
|
| 42 |
|
|
@@ -73,7 +73,7 @@ def recommend(image):
|
|
| 73 |
# Fetch images directly from the sampled dataset
|
| 74 |
results = [sampled_dataset[int(i)]["image"] for i in top_idx]
|
| 75 |
|
| 76 |
-
#
|
| 77 |
msg = (
|
| 78 |
f"Top-3 cosine similarity scores: "
|
| 79 |
f"{top_scores[0]:.3f}, {top_scores[1]:.3f}, {top_scores[2]:.3f}"
|
|
@@ -94,10 +94,8 @@ demo = gr.Interface(
|
|
| 94 |
gr.Textbox(label="Details"),
|
| 95 |
],
|
| 96 |
title="CLIP Image Recommendation System",
|
| 97 |
-
|
| 98 |
-
allow_flagging="never",
|
| 99 |
)
|
| 100 |
|
| 101 |
-
|
| 102 |
# Launch the application
|
| 103 |
demo.launch(show_error=True, ssr_mode=False)
|
|
|
|
| 36 |
sampled_indices = np.load("sampled_indices_3000.npy").astype(int).tolist()
|
| 37 |
|
| 38 |
# Load dataset and select the sampled subset
|
| 39 |
+
ds = load_dataset("JamieSJS/stanford-online-products", "corpus", split="corpus")
|
| 40 |
sampled_dataset = ds.select(sampled_indices)
|
| 41 |
|
| 42 |
|
|
|
|
| 73 |
# Fetch images directly from the sampled dataset
|
| 74 |
results = [sampled_dataset[int(i)]["image"] for i in top_idx]
|
| 75 |
|
| 76 |
+
# Return a short message for visibility
|
| 77 |
msg = (
|
| 78 |
f"Top-3 cosine similarity scores: "
|
| 79 |
f"{top_scores[0]:.3f}, {top_scores[1]:.3f}, {top_scores[2]:.3f}"
|
|
|
|
| 94 |
gr.Textbox(label="Details"),
|
| 95 |
],
|
| 96 |
title="CLIP Image Recommendation System",
|
| 97 |
+
suggests="Upload an image and receive visually similar product recommendations."
|
|
|
|
| 98 |
)
|
| 99 |
|
|
|
|
| 100 |
# Launch the application
|
| 101 |
demo.launch(show_error=True, ssr_mode=False)
|