new_hosp / copy_models.py
BSJ2004's picture
Upload 13 files
779e387 verified
# Copy Model Files Script for Hugging Face Deployment
import os
import shutil
import json
def copy_model_files():
"""Copy model files from deployment folder to Hugging Face structure"""
# Source paths
source_dir = "../hospital_readmission_model_deployment_20250910_175014/models"
# Target paths
target_dir = "models"
# Ensure target directory exists
os.makedirs(target_dir, exist_ok=True)
files_to_copy = [
"production_model.pkl",
"smoteenn_preprocessor.pkl",
"model_info.json"
]
print("πŸš€ Copying model files for Hugging Face deployment...")
for file_name in files_to_copy:
source_path = os.path.join(source_dir, file_name)
target_path = os.path.join(target_dir, file_name)
if os.path.exists(source_path):
shutil.copy2(source_path, target_path)
print(f"βœ… Copied {file_name}")
else:
print(f"❌ Source file not found: {source_path}")
print("🎯 Model files ready for Hugging Face Spaces deployment!")
# Verify files
print("\nπŸ“‹ Verification:")
for file_name in files_to_copy:
target_path = os.path.join(target_dir, file_name)
if os.path.exists(target_path):
size = os.path.getsize(target_path)
print(f" βœ… {file_name}: {size:,} bytes")
else:
print(f" ❌ {file_name}: Not found")
if __name__ == "__main__":
copy_model_files()