Spaces:
Sleeping
Sleeping
| """ | |
| Re-export models to .keras format for cross-version compatibility. | |
| """ | |
| import tensorflow as tf | |
| import os | |
| MODELS_DIR = r"C:\Users\nessi\OneDrive\Desktop\ML\alzheimer_api\models" | |
| models_to_convert = { | |
| "alzheimer_cnn_custom_best.h5": "alzheimer_cnn.keras", | |
| "alzheimer_resnet50_best.h5": "alzheimer_resnet.keras", | |
| } | |
| for h5_file, keras_file in models_to_convert.items(): | |
| h5_path = os.path.join(MODELS_DIR, h5_file) | |
| out_path = os.path.join(MODELS_DIR, keras_file) | |
| print(f"Loading {h5_file}...") | |
| model = tf.keras.models.load_model(h5_path) | |
| print(f"Saving as {keras_file}...") | |
| model.save(out_path) | |
| print(f"Done: {keras_file}\n") | |
| print("All models converted!") | |