Spaces:
Sleeping
Sleeping
| """ | |
| MelanoScope AI - Skin Lesion Classification Application | |
| Enterprise-ready deep learning application for dermatoscopic image analysis. | |
| Author: Daniel Cavadia | |
| Institution: Universidad Central de Venezuela | |
| """ | |
| import logging | |
| import sys | |
| from pathlib import Path | |
| sys.path.insert(0, str(Path(__file__).parent / "src")) | |
| from src.config.settings import LogConfig, AppConfig, EnvConfig | |
| from src.core.model import MelanoScopeModel | |
| from src.ui.components import MelanoScopeUI | |
| def setup_logging() -> None: | |
| """Configure application logging.""" | |
| log_level = getattr(logging, LogConfig.LOG_LEVEL.upper(), logging.INFO) | |
| logging.basicConfig(level=log_level, format=LogConfig.LOG_FORMAT, handlers=[logging.StreamHandler(sys.stdout)]) | |
| def create_application(): | |
| """Create and configure the application.""" | |
| logger = logging.getLogger(__name__) | |
| try: | |
| logger.info(f"Initializing {AppConfig.TITLE} v{AppConfig.VERSION}") | |
| model = MelanoScopeModel() | |
| model_info = model.get_model_info() | |
| logger.info(f"Model loaded with {model_info['num_classes']} classes") | |
| ui = MelanoScopeUI(model, model.classes) | |
| interface = ui.create_interface() | |
| logger.info("Application initialized successfully") | |
| return interface | |
| except Exception as e: | |
| logger.error(f"Application initialization failed: {e}") | |
| raise RuntimeError(f"Initialization failed: {e}") | |
| def main(): | |
| """Main entry point.""" | |
| setup_logging() | |
| logger = logging.getLogger(__name__) | |
| try: | |
| app = create_application() | |
| logger.info("Launching MelanoScope AI interface...") | |
| app.launch( | |
| server_name="0.0.0.0" if not EnvConfig.DEBUG else "127.0.0.1", | |
| server_port=7860, share=False, debug=EnvConfig.DEBUG, show_error=EnvConfig.DEBUG | |
| ) | |
| except KeyboardInterrupt: | |
| logger.info("Application shutdown requested") | |
| except Exception as e: | |
| logger.error(f"Application failed: {e}") | |
| sys.exit(1) | |
| if __name__ == "__main__": | |
| main() | |