File size: 1,557 Bytes
779e387
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# 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()