File size: 840 Bytes
2321bf7
 
1f55635
2321bf7
8de3cda
2321bf7
 
 
 
 
 
 
 
 
 
1f55635
2321bf7
 
1f55635
2321bf7
 
 
 
 
 
8de3cda
1f55635
8de3cda
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import os
import sys
import gradio as gr
from utils import load_embeddings
from ui import categorize_products, create_demo  # Updated imports

# Path to the embeddings file
EMBEDDINGS_PATH = "ingredient_embeddings_voyageai.pkl"

# Check if embeddings file exists
if not os.path.exists(EMBEDDINGS_PATH):
    print(f"Error: Embeddings file {EMBEDDINGS_PATH} not found!")
    print(f"Please ensure the file exists at {os.path.abspath(EMBEDDINGS_PATH)}")
    sys.exit(1)

# Load embeddings globally
try:
    embeddings_data = load_embeddings(EMBEDDINGS_PATH)
    # Make embeddings available to the UI functions
    import ui
    ui.embeddings = embeddings_data
except Exception as e:
    print(f"Error loading embeddings: {e}")
    sys.exit(1)

# Launch the Gradio interface
if __name__ == "__main__":
    demo = create_demo()
    demo.launch()