Spaces:
Sleeping
Sleeping
added app.py
Browse files
app.py
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import sys
|
3 |
+
from utils import load_embeddings
|
4 |
+
from ui import create_demo
|
5 |
+
|
6 |
+
# Path to the embeddings file
|
7 |
+
EMBEDDINGS_PATH = "ingredient_embeddings_voyageai.pkl"
|
8 |
+
|
9 |
+
# Check if embeddings file exists
|
10 |
+
if not os.path.exists(EMBEDDINGS_PATH):
|
11 |
+
print(f"Error: Embeddings file {EMBEDDINGS_PATH} not found!")
|
12 |
+
print(f"Please ensure the file exists at {os.path.abspath(EMBEDDINGS_PATH)}")
|
13 |
+
sys.exit(1)
|
14 |
+
|
15 |
+
# Load embeddings
|
16 |
+
try:
|
17 |
+
embeddings_data = load_embeddings(EMBEDDINGS_PATH)
|
18 |
+
# Update the embeddings in the ui module
|
19 |
+
import ui
|
20 |
+
ui.embeddings = embeddings_data
|
21 |
+
except Exception as e:
|
22 |
+
print(f"Error loading embeddings: {e}")
|
23 |
+
sys.exit(1)
|
24 |
+
|
25 |
+
# Create the Gradio interface
|
26 |
+
demo = create_demo()
|
27 |
+
|
28 |
+
# For Hugging Face Spaces, we need to use the app variable
|
29 |
+
app = demo
|