Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -18,17 +18,20 @@ app.config['UPLOAD_FOLDER'] = 'uploads'
|
|
| 18 |
# Create uploads folder if it doesn't exist
|
| 19 |
os.makedirs(app.config['UPLOAD_FOLDER'], exist_ok=True)
|
| 20 |
|
| 21 |
-
# Load the model with TensorFlow 2.
|
| 22 |
-
print("Loading model with TensorFlow 2.
|
| 23 |
import warnings
|
| 24 |
warnings.filterwarnings('ignore')
|
| 25 |
|
| 26 |
try:
|
| 27 |
-
# Load model
|
| 28 |
model = load_model('cancer_model.h5', compile=False)
|
| 29 |
print("✓ Model loaded successfully!")
|
| 30 |
except Exception as e:
|
| 31 |
print(f"❌ Error loading model: {e}")
|
|
|
|
|
|
|
|
|
|
| 32 |
import traceback
|
| 33 |
traceback.print_exc()
|
| 34 |
raise
|
|
|
|
| 18 |
# Create uploads folder if it doesn't exist
|
| 19 |
os.makedirs(app.config['UPLOAD_FOLDER'], exist_ok=True)
|
| 20 |
|
| 21 |
+
# Load the model with TensorFlow 2.11 (supports Functional class)
|
| 22 |
+
print("Loading model with TensorFlow 2.11...")
|
| 23 |
import warnings
|
| 24 |
warnings.filterwarnings('ignore')
|
| 25 |
|
| 26 |
try:
|
| 27 |
+
# Load model with Functional class support
|
| 28 |
model = load_model('cancer_model.h5', compile=False)
|
| 29 |
print("✓ Model loaded successfully!")
|
| 30 |
except Exception as e:
|
| 31 |
print(f"❌ Error loading model: {e}")
|
| 32 |
+
print("\n⚠️ MODEL FILE IS INCOMPATIBLE")
|
| 33 |
+
print("Your model file contains both old and new TensorFlow features.")
|
| 34 |
+
print("Please re-save your model in your training environment.")
|
| 35 |
import traceback
|
| 36 |
traceback.print_exc()
|
| 37 |
raise
|