Amarthya7's picture
Upload 4 files
c9f18eb verified
raw
history blame
2.16 kB
"""
MediSync: Multi-Modal Medical Analysis System - Runner Script
============================================================
This script downloads sample data and launches the MediSync application.
"""
import logging
import sys
from pathlib import Path
# Set up logging
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
handlers=[logging.StreamHandler(), logging.FileHandler("mediSync.log")],
)
logger = logging.getLogger(__name__)
def main():
"""
Main function to set up and run the MediSync application.
"""
logger.info("Starting MediSync setup")
# Add the current directory to Python path
current_dir = Path(__file__).resolve().parent
sys.path.append(str(current_dir))
# Download sample data if needed
try:
logger.info("Checking for sample data")
from mediSync.utils.download_samples import (
create_sample_info_file,
download_sample_images,
)
# Check if sample directory exists and contains images
sample_dir = current_dir / "mediSync" / "data" / "sample"
sample_dir.mkdir(parents=True, exist_ok=True)
image_files = list(sample_dir.glob("*.jpg")) + list(sample_dir.glob("*.png"))
if not image_files:
logger.info("No sample images found. Downloading...")
download_sample_images()
create_sample_info_file()
else:
logger.info(f"Found {len(image_files)} existing sample images")
except Exception as e:
logger.error(f"Error setting up sample data: {e}")
print(f"Warning: Could not set up sample data: {e}")
# Launch the application
try:
logger.info("Launching MediSync application")
from mediSync.app import create_interface
create_interface()
except Exception as e:
logger.error(f"Error launching application: {e}")
print(f"Error: Failed to launch MediSync application: {e}")
return 1
return 0
if __name__ == "__main__":
sys.exit(main())