Spaces:
Runtime error
Runtime error
Delete app.py
Browse files
app.py
DELETED
|
@@ -1,33 +0,0 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
-
from PIL import Image
|
| 3 |
-
|
| 4 |
-
size=128
|
| 5 |
-
model = build_model(input_shape=(size, size, 1))
|
| 6 |
-
model.load_weights('BreastCancerSegmentation.h5')
|
| 7 |
-
|
| 8 |
-
def preprocess_image(image, size: int=128):
|
| 9 |
-
image = cv2.resize(image, (size,size))
|
| 10 |
-
image = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)
|
| 11 |
-
image = image/255.
|
| 12 |
-
return image
|
| 13 |
-
|
| 14 |
-
def segment(image):
|
| 15 |
-
image = preprocess_image(image, size=size)
|
| 16 |
-
image = np.expand_dims(image, 0)
|
| 17 |
-
output = model.predict(image, verbose=0)
|
| 18 |
-
mask_image = output[0]
|
| 19 |
-
mask_image = np.squeeze(mask_image, -1)
|
| 20 |
-
mask_image *= 255
|
| 21 |
-
mask_image = mask_image.astype(np.uint8)
|
| 22 |
-
mask_image = Image.fromarray(mask_image).convert("L")
|
| 23 |
-
return mask_image
|
| 24 |
-
|
| 25 |
-
if __name__ == "__main__":
|
| 26 |
-
gr.Interface(
|
| 27 |
-
fn=segment,
|
| 28 |
-
inputs="image",
|
| 29 |
-
outputs=gr.Image(type="pil", label="Breast Cancer Mask"),
|
| 30 |
-
examples = [["/content/benign(10).png"], ["/content/benign(109).png"]],
|
| 31 |
-
title = "Breast Cancer Ultrasound Image Segmentation",
|
| 32 |
-
description = "Check out this exciting development in the field of breast cancer diagnosis and treatment! A demo of Breast Cancer Ultrasound Image Segmentation has been developed. Upload image file, or try out one of the examples below!"
|
| 33 |
-
).launch(share=True, debug=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|