Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -100,6 +100,17 @@ def build_interface():
|
|
| 100 |
# --- Boot ---
|
| 101 |
df = load_dataset()
|
| 102 |
model, embs = build_embeddings(df["Unhealthy_Food"].astype(str).tolist())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
app = build_interface()
|
| 104 |
|
| 105 |
if __name__ == "__main__":
|
|
|
|
| 100 |
# --- Boot ---
|
| 101 |
df = load_dataset()
|
| 102 |
model, embs = build_embeddings(df["Unhealthy_Food"].astype(str).tolist())
|
| 103 |
+
def quick_eval(samples=("Hamburger","Nachos","Pepperoni Pizza")):
|
| 104 |
+
print("=== Quick Eval (cosine top-1 row -> 3 alts) ===")
|
| 105 |
+
for s in samples:
|
| 106 |
+
idx = cosine_top_row(s, model, embs)
|
| 107 |
+
r = df.iloc[idx]
|
| 108 |
+
print(f"\nQuery: {s} -> Row match: {r['Unhealthy_Food']}")
|
| 109 |
+
for x in to_three_alternatives(r):
|
| 110 |
+
print(f" {x['Rank']}. {x['Healthier Alternative']} | {x['Calorie/Nutrient Difference']}")
|
| 111 |
+
|
| 112 |
+
# call it once at startup
|
| 113 |
+
quick_eval()
|
| 114 |
app = build_interface()
|
| 115 |
|
| 116 |
if __name__ == "__main__":
|