""" Main Application Entry Point Multilingual Question Answering System with Gradio Interface """ import sys from pathlib import Path # Add project root to path project_root = Path(__file__).parent sys.path.insert(0, str(project_root)) from app.model_loader import ModelLoader from app.inference import QAInference from app.interface import create_interface def main(): """Main application entry point""" print("=" * 80) print("šŸš€ INITIALIZING MULTILINGUAL QA SYSTEM") print("=" * 80) # Configuration MODEL_PATH = "Praanshull/multilingual-qa-model" # Change this to your model path # Load model print(f"\nšŸ“‚ Model path: {MODEL_PATH}") loader = ModelLoader(model_path=MODEL_PATH) try: model, tokenizer = loader.load() except Exception as e: print(f"\nāŒ Failed to load model: {e}") print("\nšŸ’” Please ensure:") print(f" 1. Model exists at: {MODEL_PATH}") print(" 2. All required files are present") print(" 3. You have sufficient memory") return # Create inference engine print("\nšŸ”§ Initializing inference engine...") inference_engine = QAInference( model=model, tokenizer=tokenizer, device=loader.device ) print("āœ… Inference engine ready") # Create interface print("\nšŸŽØ Building Gradio interface...") demo = create_interface(inference_engine) print("āœ… Interface created") # Launch print("\n" + "=" * 80) print("šŸš€ LAUNCHING APPLICATION") print("=" * 80) # Custom CSS custom_css = """ .gradio-container { font-family: 'Arial', sans-serif; } .header { text-align: center; padding: 20px; background: linear-gradient(90deg, #3498db, #e74c3c); color: white; border-radius: 10px; margin-bottom: 20px; } """ demo.launch( server_name="0.0.0.0", # Allow external access server_port=7860, # Default Gradio port share=False, # Set to True for public URL show_error=True, quiet=False, css=custom_css ) print("\nāœ… Application launched successfully!") print("šŸ“± Access the interface at: http://localhost:7860") print("\nšŸ’” TIP: Set share=True in demo.launch() to get a public URL") print("=" * 80) if __name__ == "__main__": main()