Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -24,22 +24,20 @@ os.environ['TF_FORCE_GPU_ALLOW_GROWTH'] = 'true'
|
|
| 24 |
# Try loading with h5py directly for better compatibility
|
| 25 |
import h5py
|
| 26 |
|
|
|
|
| 27 |
try:
|
| 28 |
-
#
|
| 29 |
-
from
|
| 30 |
-
model =
|
| 31 |
-
print("Model loaded successfully with
|
| 32 |
except Exception as e:
|
| 33 |
-
print(f"
|
| 34 |
try:
|
| 35 |
-
#
|
| 36 |
-
model = load_model('cancer_model.h5', compile=False)
|
| 37 |
-
print("Model loaded successfully!")
|
| 38 |
except Exception as e2:
|
| 39 |
-
print(f"
|
| 40 |
-
print("\nPlease re-save your model using:")
|
| 41 |
-
print(" model.save('cancer_model.h5', save_format='h5')")
|
| 42 |
-
print("Or convert to SavedModel format for better compatibility")
|
| 43 |
raise
|
| 44 |
|
| 45 |
def resize_with_padding(img, target_size):
|
|
|
|
| 24 |
# Try loading with h5py directly for better compatibility
|
| 25 |
import h5py
|
| 26 |
|
| 27 |
+
# Load model with old TensorFlow/Keras compatibility
|
| 28 |
try:
|
| 29 |
+
# Direct loading with old Keras
|
| 30 |
+
from keras.models import load_model as keras_load_model
|
| 31 |
+
model = keras_load_model('cancer_model.h5', compile=False)
|
| 32 |
+
print("✓ Model loaded successfully with Keras 2.4.3!")
|
| 33 |
except Exception as e:
|
| 34 |
+
print(f"Keras loader failed: {e}")
|
| 35 |
try:
|
| 36 |
+
# Try TensorFlow loader
|
| 37 |
+
model = tf.keras.models.load_model('cancer_model.h5', compile=False)
|
| 38 |
+
print("✓ Model loaded successfully with TensorFlow!")
|
| 39 |
except Exception as e2:
|
| 40 |
+
print(f"Error: {e2}")
|
|
|
|
|
|
|
|
|
|
| 41 |
raise
|
| 42 |
|
| 43 |
def resize_with_padding(img, target_size):
|