Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,8 +7,7 @@ from werkzeug.utils import secure_filename
|
|
| 7 |
# Suppress TensorFlow warnings
|
| 8 |
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
|
| 9 |
|
| 10 |
-
|
| 11 |
-
# Use standalone Keras (compatible with old models)
|
| 12 |
from keras.models import load_model
|
| 13 |
|
| 14 |
app = Flask(__name__)
|
|
@@ -18,17 +17,19 @@ 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
|
| 22 |
-
print("Loading model...")
|
| 23 |
import warnings
|
| 24 |
warnings.filterwarnings('ignore')
|
| 25 |
|
| 26 |
try:
|
| 27 |
-
#
|
| 28 |
model = load_model('cancer_model.h5', compile=False)
|
| 29 |
-
print("✓ Model loaded successfully with Keras 2.
|
| 30 |
except Exception as e:
|
| 31 |
print(f"❌ Error loading model: {e}")
|
|
|
|
|
|
|
| 32 |
raise
|
| 33 |
|
| 34 |
def resize_with_padding(img, target_size):
|
|
|
|
| 7 |
# Suppress TensorFlow warnings
|
| 8 |
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
|
| 9 |
|
| 10 |
+
# Use Keras 2.2.5 (compatible with Keras 2.0 models)
|
|
|
|
| 11 |
from keras.models import load_model
|
| 12 |
|
| 13 |
app = Flask(__name__)
|
|
|
|
| 17 |
# Create uploads folder if it doesn't exist
|
| 18 |
os.makedirs(app.config['UPLOAD_FOLDER'], exist_ok=True)
|
| 19 |
|
| 20 |
+
# Load the model with Keras 2.2.5 (supports batch_shape)
|
| 21 |
+
print("Loading model with Keras 2.2.5...")
|
| 22 |
import warnings
|
| 23 |
warnings.filterwarnings('ignore')
|
| 24 |
|
| 25 |
try:
|
| 26 |
+
# Keras 2.2.5 natively supports batch_shape parameter
|
| 27 |
model = load_model('cancer_model.h5', compile=False)
|
| 28 |
+
print("✓ Model loaded successfully with Keras 2.2.5!")
|
| 29 |
except Exception as e:
|
| 30 |
print(f"❌ Error loading model: {e}")
|
| 31 |
+
import traceback
|
| 32 |
+
traceback.print_exc()
|
| 33 |
raise
|
| 34 |
|
| 35 |
def resize_with_padding(img, target_size):
|