Spaces:
Sleeping
Sleeping
| #!/usr/bin/env python3 | |
| """ | |
| Script to deploy the Patient Evaluation App to Hugging Face Spaces for permanent hosting. | |
| This will give you a permanent URL that doesn't expire. | |
| """ | |
| import os | |
| import subprocess | |
| import sys | |
| def check_requirements(): | |
| """Check if required packages are installed""" | |
| try: | |
| import gradio | |
| print("β Gradio is installed") | |
| except ImportError: | |
| print("β Gradio not found. Please install with: pip install gradio") | |
| return False | |
| try: | |
| subprocess.run(["huggingface-cli", "--help"], capture_output=True, check=True) | |
| print("β Hugging Face CLI is available") | |
| except (subprocess.CalledProcessError, FileNotFoundError): | |
| print("β Hugging Face CLI not found. Please install with: pip install huggingface_hub[cli]") | |
| return False | |
| return True | |
| def check_login(): | |
| """Check if user is logged into Hugging Face""" | |
| try: | |
| result = subprocess.run(["huggingface-cli", "whoami"], capture_output=True, text=True) | |
| if result.returncode == 0: | |
| print(f"β Logged in as: {result.stdout.strip()}") | |
| return True | |
| else: | |
| print("β Not logged into Hugging Face") | |
| return False | |
| except Exception as e: | |
| print(f"β Error checking login status: {e}") | |
| return False | |
| def create_space_config(): | |
| """Create the space configuration file""" | |
| config_content = """--- | |
| title: Patient Evaluation System | |
| emoji: π₯ | |
| colorFrom: blue | |
| colorTo: green | |
| sdk: gradio | |
| sdk_version: 3.50.2 | |
| app_file: chatgpt.py | |
| pinned: false | |
| license: mit | |
| --- | |
| # Patient Evaluation System | |
| A comprehensive system for medical experts to evaluate AI-generated patient summaries. | |
| ## Features | |
| - Multi-admission patient data evaluation | |
| - Simplified comment system | |
| - Google Drive integration for data backup | |
| - Real-time statistics and analytics | |
| - CSV/JSON data export | |
| ## Usage | |
| 1. Select a patient sample from the evaluation tab | |
| 2. Review the AI-generated summary against the original data | |
| 3. Provide ratings and feedback | |
| 4. Submit evaluation for analysis | |
| ## Setup | |
| The application will guide you through any necessary setup steps. | |
| """ | |
| with open("README.md", "w") as f: | |
| f.write(config_content) | |
| print("β Created README.md for Hugging Face Space") | |
| def deploy(): | |
| """Deploy to Hugging Face Spaces""" | |
| if not check_requirements(): | |
| return False | |
| if not check_login(): | |
| print("\nπ Please login to Hugging Face first:") | |
| print("Run: huggingface-cli login") | |
| print("Then run this script again.") | |
| return False | |
| print("\nπ Starting deployment to Hugging Face Spaces...") | |
| # Create space config | |
| create_space_config() | |
| try: | |
| # Deploy using gradio | |
| print("π€ Deploying application...") | |
| result = subprocess.run(["gradio", "deploy", "--hf-token"], | |
| input="y\n", text=True, capture_output=True) | |
| if result.returncode == 0: | |
| print("β Deployment successful!") | |
| print("\nπ Your permanent URL will be:") | |
| print("https://your-username-patient-evaluation.hf.space") | |
| print("\nπ‘ Tips:") | |
| print("- The URL will be permanent and won't expire") | |
| print("- You can update the app by running this script again") | |
| print("- Your Google Drive data will be preserved") | |
| return True | |
| else: | |
| print(f"β Deployment failed: {result.stderr}") | |
| return False | |
| except Exception as e: | |
| print(f"β Error during deployment: {e}") | |
| return False | |
| def main(): | |
| print("π₯ Patient Evaluation System - Hugging Face Deployment") | |
| print("=" * 60) | |
| print("\nπ This script will deploy your app to Hugging Face Spaces") | |
| print("Benefits:") | |
| print("- β Permanent URL (no 72-hour expiry)") | |
| print("- β Free hosting") | |
| print("- β HTTPS security") | |
| print("- β Easy updates") | |
| answer = input("\nβ Do you want to proceed? (y/n): ").lower().strip() | |
| if answer in ['y', 'yes']: | |
| if deploy(): | |
| print("\nπ Deployment completed successfully!") | |
| else: | |
| print("\nπ Deployment failed. Please check the errors above.") | |
| else: | |
| print("π Deployment cancelled.") | |
| if __name__ == "__main__": | |
| main() | |