Update app.py
Browse files
app.py
CHANGED
@@ -9,12 +9,13 @@ import gradio as gr
|
|
9 |
|
10 |
pd.options.mode.chained_assignment = None
|
11 |
|
12 |
-
# Load precomputed embeddings
|
13 |
embeddings = pickle.load(open(
|
14 |
-
hf_hub_download("
|
15 |
|
16 |
-
# Load meme metadata
|
17 |
-
df = pd.read_csv(
|
|
|
18 |
|
19 |
# Load model
|
20 |
model = SentenceTransformer('sentence-transformers/all-mpnet-base-v2')
|
@@ -37,15 +38,15 @@ def generate_memes(prompt):
|
|
37 |
print(f"Error loading image {url}: {e}")
|
38 |
return images
|
39 |
|
40 |
-
# UI
|
41 |
-
input_textbox = gr.Textbox(lines=1, label="
|
42 |
-
output_gallery = gr.Gallery(label="
|
43 |
|
44 |
-
title = "
|
45 |
-
description = "Search memes from a dataset
|
46 |
-
examples = ["
|
47 |
|
48 |
-
#
|
49 |
iface = gr.Interface(
|
50 |
fn=generate_memes,
|
51 |
inputs=input_textbox,
|
|
|
9 |
|
10 |
pd.options.mode.chained_assignment = None
|
11 |
|
12 |
+
# Load precomputed embeddings from your dataset repo
|
13 |
embeddings = pickle.load(open(
|
14 |
+
hf_hub_download("Go-Raw/semantic-memes", repo_type="dataset", filename="meme-embeddings.pkl"), "rb"))
|
15 |
|
16 |
+
# Load meme metadata from your dataset repo
|
17 |
+
df = pd.read_csv(
|
18 |
+
hf_hub_download("Go-Raw/semantic-memes", repo_type="dataset", filename="semantic_memes.csv"))
|
19 |
|
20 |
# Load model
|
21 |
model = SentenceTransformer('sentence-transformers/all-mpnet-base-v2')
|
|
|
38 |
print(f"Error loading image {url}: {e}")
|
39 |
return images
|
40 |
|
41 |
+
# Gradio UI
|
42 |
+
input_textbox = gr.Textbox(lines=1, label="Type your vibe here 🧠")
|
43 |
+
output_gallery = gr.Gallery(label="Your Meme Results", columns=3, rows=2, height="auto")
|
44 |
|
45 |
+
title = "🧠 Meme Lord"
|
46 |
+
description = "Search Indian memes from a custom dataset using semantic similarity. Built using Sentence Transformers & Hugging Face. [Dataset](https://huggingface.co/datasets/Go-Raw/semantic-memes)"
|
47 |
+
examples = ["When the professor says 'open book exam'", "Shaktimaan saves the day", "Tu janta nahi mera baap kaun hai"]
|
48 |
|
49 |
+
# Launch app
|
50 |
iface = gr.Interface(
|
51 |
fn=generate_memes,
|
52 |
inputs=input_textbox,
|