""" MediSync: Multi-Modal Medical Analysis System - Hugging Face Spaces Entry Point ============================================================================== This is the main entry point for the Hugging Face Space deployment. """ import logging import os import sys from pathlib import Path # Configure logging logging.basicConfig( level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", handlers=[logging.StreamHandler()], ) logger = logging.getLogger(__name__) # Add the current directory to Python path current_dir = Path(__file__).resolve().parent sys.path.append(str(current_dir)) # Pre-download models (important for Hugging Face Spaces) try: logger.info("Pre-downloading models for caching...") from transformers import AutoModel, AutoModelForImageClassification, AutoTokenizer # Set cache directory (HF Spaces specific) os.environ["TRANSFORMERS_CACHE"] = os.path.join(os.getcwd(), "model_cache") os.makedirs(os.environ["TRANSFORMERS_CACHE"], exist_ok=True) # Medical vision model vision_model_name = "facebook/deit-base-patch16-224-medical-cxr" logger.info(f"Downloading vision model: {vision_model_name}") AutoModelForImageClassification.from_pretrained(vision_model_name) # Clinical BERT model text_model_name = "medicalai/ClinicalBERT" logger.info(f"Downloading text model: {text_model_name}") AutoModel.from_pretrained(text_model_name) AutoTokenizer.from_pretrained(text_model_name) logger.info("All models downloaded and cached successfully!") except Exception as e: logger.warning(f"Warning: Could not pre-download models: {e}") # Import and run the MediSync application from mediSync.app import create_interface # Create and launch the interface logger.info("Creating and launching the interface...") interface = create_interface() # For Hugging Face Spaces if __name__ == "__main__": interface.launch()