Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from src.models.text_classification import TextClassificationModel | |
| import logging | |
| # Configure logging | |
| logging.basicConfig(level=logging.INFO) | |
| logger = logging.getLogger(__name__) | |
| def create_demo(): | |
| try: | |
| # Initialize the model | |
| logger.info("Initializing Text Classification model...") | |
| model = TextClassificationModel() | |
| # Create the interface | |
| logger.info("Creating Gradio interface...") | |
| demo = model.create_interface() | |
| logger.info("Gradio interface created successfully") | |
| return demo | |
| except Exception as e: | |
| logger.error(f"Error creating demo: {str(e)}") | |
| raise | |
| if __name__ == "__main__": | |
| try: | |
| logger.info("Starting the application...") | |
| demo = create_demo() | |
| logger.info("Launching the interface...") | |
| demo.launch( | |
| server_name="0.0.0.0", # Allow external connections | |
| server_port=7860, # Specify port explicitly | |
| share=True # Enable public URL | |
| ) | |
| logger.info("Interface launched successfully") | |
| except Exception as e: | |
| logger.error(f"Application error: {str(e)}") | |
| raise |