Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -31,25 +31,8 @@ custom_style = """
|
|
31 |
|
32 |
st.markdown(custom_style, unsafe_allow_html=True)
|
33 |
|
34 |
-
def preprocess_image(img):
|
35 |
-
img = img.resize(img_size)
|
36 |
-
img_array = image.img_to_array(img)
|
37 |
-
img_array = img_array / 255.0
|
38 |
-
img_array = np.expand_dims(img_array, axis=0)
|
39 |
-
return img_array
|
40 |
|
41 |
-
def predict_tumor_segmentation(img):
|
42 |
-
img_array = preprocess_image(img)
|
43 |
-
segmentation_mask = model.predict(img_array)
|
44 |
-
segmentation_mask = np.squeeze(segmentation_mask, axis=0)
|
45 |
-
return segmentation_mask
|
46 |
|
47 |
-
def display_segmentation_result(original_image, segmentation_mask):
|
48 |
-
original_image = np.array(original_image)
|
49 |
-
segmentation_mask = (segmentation_mask > 0.5).astype(np.uint8) * 255
|
50 |
-
segmentation_mask = Image.fromarray(segmentation_mask, 'L')
|
51 |
-
|
52 |
-
st.image([original_image, segmentation_mask], caption=['Original Image', 'Segmentation Mask'], use_column_width=True)
|
53 |
|
54 |
def main():
|
55 |
st.title("Brain Tumor Segmentation App")
|
@@ -62,11 +45,5 @@ def main():
|
|
62 |
|
63 |
st.markdown("## Tumor Segmentation Result")
|
64 |
|
65 |
-
# Perform segmentation
|
66 |
-
segmentation_mask = predict_tumor_segmentation(original_image)
|
67 |
-
|
68 |
-
# Display the segmentation result
|
69 |
-
display_segmentation_result(original_image, segmentation_mask)
|
70 |
-
|
71 |
if __name__ == "__main__":
|
72 |
main()
|
|
|
31 |
|
32 |
st.markdown(custom_style, unsafe_allow_html=True)
|
33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
|
|
|
|
|
|
|
|
|
|
35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
|
37 |
def main():
|
38 |
st.title("Brain Tumor Segmentation App")
|
|
|
45 |
|
46 |
st.markdown("## Tumor Segmentation Result")
|
47 |
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
if __name__ == "__main__":
|
49 |
main()
|