koesan commited on
Commit
bd36261
·
verified ·
1 Parent(s): 124124b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
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 Keras 2.2.5 (compatible with Keras 2.0 models)
11
- from keras.models import load_model
 
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 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
 
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