|
|
|
|
|
|
|
|
import os
|
|
|
import shutil
|
|
|
import json
|
|
|
|
|
|
def copy_model_files():
|
|
|
"""Copy model files from deployment folder to Hugging Face structure"""
|
|
|
|
|
|
|
|
|
source_dir = "../hospital_readmission_model_deployment_20250910_175014/models"
|
|
|
|
|
|
|
|
|
target_dir = "models"
|
|
|
|
|
|
|
|
|
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!")
|
|
|
|
|
|
|
|
|
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()
|
|
|
|