Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,8 +7,9 @@ from werkzeug.utils import secure_filename
|
|
| 7 |
# Suppress TensorFlow warnings
|
| 8 |
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
|
| 9 |
|
| 10 |
-
# Use
|
| 11 |
-
|
|
|
|
| 12 |
|
| 13 |
app = Flask(__name__)
|
| 14 |
app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024 # 16MB max file size
|
|
@@ -17,15 +18,15 @@ app.config['UPLOAD_FOLDER'] = 'uploads'
|
|
| 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
|
| 21 |
-
print("Loading model with
|
| 22 |
import warnings
|
| 23 |
warnings.filterwarnings('ignore')
|
| 24 |
|
| 25 |
try:
|
| 26 |
-
#
|
| 27 |
model = load_model('cancer_model.h5', compile=False)
|
| 28 |
-
print("✓ Model loaded successfully with
|
| 29 |
except Exception as e:
|
| 30 |
print(f"❌ Error loading model: {e}")
|
| 31 |
import traceback
|
|
|
|
| 7 |
# Suppress TensorFlow warnings
|
| 8 |
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
|
| 9 |
|
| 10 |
+
# Use TensorFlow 2.0 integrated Keras
|
| 11 |
+
import tensorflow as tf
|
| 12 |
+
from tensorflow.keras.models import load_model
|
| 13 |
|
| 14 |
app = Flask(__name__)
|
| 15 |
app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024 # 16MB max file size
|
|
|
|
| 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.0
|
| 22 |
+
print("Loading model with TensorFlow 2.0...")
|
| 23 |
import warnings
|
| 24 |
warnings.filterwarnings('ignore')
|
| 25 |
|
| 26 |
try:
|
| 27 |
+
# TensorFlow 2.0 should handle Functional models
|
| 28 |
model = load_model('cancer_model.h5', compile=False)
|
| 29 |
+
print("✓ Model loaded successfully with TensorFlow 2.0!")
|
| 30 |
except Exception as e:
|
| 31 |
print(f"❌ Error loading model: {e}")
|
| 32 |
import traceback
|