Deploy app with recommendation + slogan generator
Browse files- app.py +65 -0
- requirements.txt +7 -0
app.py
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
import gradio as gr
|
3 |
+
import pandas as pd
|
4 |
+
import numpy as np
|
5 |
+
from sentence_transformers import SentenceTransformer
|
6 |
+
import faiss
|
7 |
+
|
8 |
+
# === Load embedding model ===
|
9 |
+
embed_model = SentenceTransformer("sentence-transformers/all-mpnet-base-v2")
|
10 |
+
|
11 |
+
# Dummy dataset (for demo) – replace with your full startup dataset
|
12 |
+
data = pd.DataFrame({
|
13 |
+
"name": ["HowDidIDo", "Museotainment", "Movitr"],
|
14 |
+
"tagline": ["Online evaluation platform", "PacMan & Louvre meet", "Crowdsourced video translation"],
|
15 |
+
"description": [
|
16 |
+
"Public speaking, Presentation skills and interview practice",
|
17 |
+
"Interactive AR museum tours",
|
18 |
+
"Video translation with voice and subtitles"
|
19 |
+
]
|
20 |
+
})
|
21 |
+
|
22 |
+
# Build FAISS index
|
23 |
+
data_vecs = embed_model.encode(data["description"].tolist())
|
24 |
+
faiss.normalize_L2(data_vecs)
|
25 |
+
index = faiss.IndexFlatIP(data_vecs.shape[1])
|
26 |
+
index.add(data_vecs)
|
27 |
+
|
28 |
+
def recommend(query, top_k=3):
|
29 |
+
query_vec = embed_model.encode([query])
|
30 |
+
faiss.normalize_L2(query_vec)
|
31 |
+
scores, idx = index.search(query_vec, top_k)
|
32 |
+
results = data.iloc[idx[0]].copy()
|
33 |
+
results["score"] = scores[0]
|
34 |
+
return results[["name", "tagline", "description", "score"]]
|
35 |
+
|
36 |
+
def generate_slogan(description):
|
37 |
+
# Very simple slogan generator – can be replaced with FLAN-T5 later
|
38 |
+
return "Fresh Ideas for " + description.split()[0]
|
39 |
+
|
40 |
+
def pipeline(user_input):
|
41 |
+
recs = recommend(user_input, top_k=3)
|
42 |
+
slogan = generate_slogan(user_input)
|
43 |
+
recs = recs.reset_index(drop=True)
|
44 |
+
recs.loc[len(recs)] = ["Generated Slogan", slogan, user_input, np.nan]
|
45 |
+
return recs
|
46 |
+
|
47 |
+
examples = [
|
48 |
+
"AI coach for improving public speaking skills",
|
49 |
+
"Augmented reality app for interactive museum tours",
|
50 |
+
"Voice-controlled task manager for remote teams",
|
51 |
+
"Machine learning system for predicting crop yields",
|
52 |
+
"Platform for AI-assisted interior design suggestions"
|
53 |
+
]
|
54 |
+
|
55 |
+
demo = gr.Interface(
|
56 |
+
fn=pipeline,
|
57 |
+
inputs=gr.Textbox(label="Enter a startup description"),
|
58 |
+
outputs=gr.Dataframe(headers=["Name", "Tagline", "Description", "Score"]),
|
59 |
+
examples=examples,
|
60 |
+
title="SloganAI – Startup Recommendation & Slogan Generator",
|
61 |
+
description="Enter a startup idea and get top-3 similar startups + 1 generated slogan."
|
62 |
+
)
|
63 |
+
|
64 |
+
if __name__ == "__main__":
|
65 |
+
demo.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
gradio
|
2 |
+
transformers
|
3 |
+
sentence-transformers
|
4 |
+
faiss-cpu
|
5 |
+
pandas
|
6 |
+
numpy
|
7 |
+
torch
|