import argparse import os import sys import gradio as gr from utils import load_embeddings from ui import create_demo from config import UI_THEME from ui_formatters import set_theme def main(): """Main entry point for the application""" parser = argparse.ArgumentParser(description='Run the Product Categorization web app') parser.add_argument('--embeddings', default='data/ingredient_embeddings_voyageai.pkl', help='Path to the ingredient embeddings pickle file') parser.add_argument('--share', action='store_true', help='Create a public link for sharing') args = parser.parse_args() # Check if embeddings file exists if not os.path.exists(args.embeddings): print(f"Error: Embeddings file {args.embeddings} not found!") print(f"Please ensure the file exists at {os.path.abspath(args.embeddings)}") sys.exit(1) # Load embeddings try: embeddings_data = load_embeddings(args.embeddings) # Update the embeddings in the ui_core module import ui_core ui_core.embeddings = embeddings_data except Exception as e: print(f"Error loading embeddings: {e}") sys.exit(1) # Set the application theme set_theme(UI_THEME) # Create and launch the interface demo = create_demo() # Launch with only supported parameters demo.launch( share=args.share, show_api=False ) if __name__ == "__main__": main()