Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -4,11 +4,21 @@ import cv2
|
|
4 |
from flask import Flask, request, jsonify, render_template
|
5 |
from tensorflow.keras.models import load_model # type: ignore
|
6 |
|
7 |
-
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
# Load the saved model
|
11 |
-
|
|
|
|
|
|
|
|
|
12 |
|
13 |
def preprocess_image(image):
|
14 |
"""Preprocess the image for prediction."""
|
|
|
4 |
from flask import Flask, request, jsonify, render_template
|
5 |
from tensorflow.keras.models import load_model # type: ignore
|
6 |
|
7 |
+
app = Flask(__name__)
|
8 |
+
|
9 |
+
# Path to the model file
|
10 |
+
model_path = 'pneumonia_model_final.keras'
|
11 |
+
|
12 |
+
# Check if the model file exists
|
13 |
+
if not os.path.exists(model_path):
|
14 |
+
raise FileNotFoundError(f"The model file {model_path} does not exist.")
|
15 |
|
16 |
# Load the saved model
|
17 |
+
try:
|
18 |
+
model = load_model(model_path)
|
19 |
+
except ValueError as e:
|
20 |
+
print(f"Error loading the model: {e}")
|
21 |
+
raise
|
22 |
|
23 |
def preprocess_image(image):
|
24 |
"""Preprocess the image for prediction."""
|