Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -7,13 +7,16 @@ from tensorflow.keras.preprocessing import image
|
|
7 |
model = tf.keras.models.load_model('Tumor_Model.h5')
|
8 |
|
9 |
def predict_input_image(img):
|
10 |
-
#
|
11 |
-
img =
|
12 |
-
img =
|
|
|
|
|
|
|
13 |
# Make predictions
|
14 |
-
prediction = model.predict(img)
|
15 |
result = 'No Tumor Detected' if prediction[0][0] > 0.5 else 'Tumor detected'
|
16 |
-
|
17 |
return f"Prediction: {result}"
|
18 |
|
19 |
# Define Gradio interface
|
@@ -24,4 +27,4 @@ iface = gr.Interface(
|
|
24 |
)
|
25 |
|
26 |
# Launch the interface
|
27 |
-
iface.launch()
|
|
|
7 |
model = tf.keras.models.load_model('Tumor_Model.h5')
|
8 |
|
9 |
def predict_input_image(img):
|
10 |
+
# Convert NumPy array to PIL.Image
|
11 |
+
img = Image.fromarray(np.uint8(img))
|
12 |
+
img = img.convert('RGB')
|
13 |
+
img = img.resize((224, 224))
|
14 |
+
img = np.array(img).reshape(1, 224, 224, 3) # Reshape the image to match the model input
|
15 |
+
|
16 |
# Make predictions
|
17 |
+
prediction = model.predict(img)
|
18 |
result = 'No Tumor Detected' if prediction[0][0] > 0.5 else 'Tumor detected'
|
19 |
+
|
20 |
return f"Prediction: {result}"
|
21 |
|
22 |
# Define Gradio interface
|
|
|
27 |
)
|
28 |
|
29 |
# Launch the interface
|
30 |
+
iface.launch(debug = True)
|