Delete app.py
Browse files
app.py
DELETED
|
@@ -1,57 +0,0 @@
|
|
| 1 |
-
"""
|
| 2 |
-
MediSync: Multi-Modal Medical Analysis System - Hugging Face Spaces Entry Point
|
| 3 |
-
==============================================================================
|
| 4 |
-
This is the main entry point for the Hugging Face Space deployment.
|
| 5 |
-
"""
|
| 6 |
-
|
| 7 |
-
import logging
|
| 8 |
-
import os
|
| 9 |
-
import sys
|
| 10 |
-
from pathlib import Path
|
| 11 |
-
|
| 12 |
-
# Configure logging
|
| 13 |
-
logging.basicConfig(
|
| 14 |
-
level=logging.INFO,
|
| 15 |
-
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
|
| 16 |
-
handlers=[logging.StreamHandler()],
|
| 17 |
-
)
|
| 18 |
-
logger = logging.getLogger(__name__)
|
| 19 |
-
|
| 20 |
-
# Add the current directory to Python path
|
| 21 |
-
current_dir = Path(__file__).resolve().parent
|
| 22 |
-
sys.path.append(str(current_dir))
|
| 23 |
-
|
| 24 |
-
# Pre-download models (important for Hugging Face Spaces)
|
| 25 |
-
try:
|
| 26 |
-
logger.info("Pre-downloading models for caching...")
|
| 27 |
-
from transformers import AutoModel, AutoModelForImageClassification, AutoTokenizer
|
| 28 |
-
|
| 29 |
-
# Set cache directory (HF Spaces specific)
|
| 30 |
-
os.environ["TRANSFORMERS_CACHE"] = os.path.join(os.getcwd(), "model_cache")
|
| 31 |
-
os.makedirs(os.environ["TRANSFORMERS_CACHE"], exist_ok=True)
|
| 32 |
-
|
| 33 |
-
# Medical vision model
|
| 34 |
-
vision_model_name = "facebook/deit-base-patch16-224-medical-cxr"
|
| 35 |
-
logger.info(f"Downloading vision model: {vision_model_name}")
|
| 36 |
-
AutoModelForImageClassification.from_pretrained(vision_model_name)
|
| 37 |
-
|
| 38 |
-
# Clinical BERT model
|
| 39 |
-
text_model_name = "medicalai/ClinicalBERT"
|
| 40 |
-
logger.info(f"Downloading text model: {text_model_name}")
|
| 41 |
-
AutoModel.from_pretrained(text_model_name)
|
| 42 |
-
AutoTokenizer.from_pretrained(text_model_name)
|
| 43 |
-
|
| 44 |
-
logger.info("All models downloaded and cached successfully!")
|
| 45 |
-
except Exception as e:
|
| 46 |
-
logger.warning(f"Warning: Could not pre-download models: {e}")
|
| 47 |
-
|
| 48 |
-
# Import and run the MediSync application
|
| 49 |
-
from mediSync.app import create_interface
|
| 50 |
-
|
| 51 |
-
# Create and launch the interface
|
| 52 |
-
logger.info("Creating and launching the interface...")
|
| 53 |
-
interface = create_interface()
|
| 54 |
-
|
| 55 |
-
# For Hugging Face Spaces
|
| 56 |
-
if __name__ == "__main__":
|
| 57 |
-
interface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|