Commit ·
ea62197
1
Parent(s): 4f37c6b
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,17 +2,13 @@ import os, io
|
|
| 2 |
import cv2
|
| 3 |
import gradio as gr
|
| 4 |
import tensorflow as tf
|
| 5 |
-
import urllib.request
|
| 6 |
import numpy as np
|
| 7 |
import keras.backend as K
|
| 8 |
-
from transformers import pipeline
|
| 9 |
-
from matplotlib import pyplot as plt
|
| 10 |
|
|
|
|
| 11 |
from PIL import Image
|
| 12 |
-
from matplotlib import cm
|
| 13 |
from tensorflow import keras
|
| 14 |
|
| 15 |
-
from matplotlib import cm
|
| 16 |
|
| 17 |
resized_shape = (768, 768, 3)
|
| 18 |
IMG_SCALING = (1, 1)
|
|
@@ -51,7 +47,7 @@ def dice_coef(y_true, y_pred, smooth=1):
|
|
| 51 |
seg_model = keras.models.load_model('seg_unet_model.h5', custom_objects={'Combo_loss': Combo_loss, 'dice_coef': dice_coef})
|
| 52 |
|
| 53 |
# inputs = gr.inputs.Image(type="pil", label="Upload an image")
|
| 54 |
-
image_output = gr.outputs.Image(type="pil", label="Output Image")
|
| 55 |
# outputs = gr.outputs.HTML() #uncomment for single class output
|
| 56 |
|
| 57 |
rows = 1
|
|
@@ -70,16 +66,14 @@ def gen_pred(img, model=seg_model):
|
|
| 70 |
pred = np.squeeze(pred, axis=0)
|
| 71 |
fig = plt.figure(figsize=(10, 7))
|
| 72 |
fig.add_subplot(rows, columns, 1)
|
| 73 |
-
plt.imshow(pred, interpolation='catrom')
|
|
|
|
| 74 |
plt.axis('off')
|
| 75 |
-
plt.title("Prediction")
|
| 76 |
plt.show()
|
| 77 |
-
# return "UI in developing process ..."
|
| 78 |
return fig
|
| 79 |
|
| 80 |
title = "<h1 style='text-align: center;'>Semantic Segmentation</h1>"
|
| 81 |
description = "Upload an image and get prediction mask"
|
| 82 |
-
# css_code='body{background-image:url("file=wave.mp4");}'
|
| 83 |
|
| 84 |
gr.Interface(fn=gen_pred,
|
| 85 |
inputs=[gr.Image(type='pil')],
|
|
|
|
| 2 |
import cv2
|
| 3 |
import gradio as gr
|
| 4 |
import tensorflow as tf
|
|
|
|
| 5 |
import numpy as np
|
| 6 |
import keras.backend as K
|
|
|
|
|
|
|
| 7 |
|
| 8 |
+
from matplotlib import pyplot as plt
|
| 9 |
from PIL import Image
|
|
|
|
| 10 |
from tensorflow import keras
|
| 11 |
|
|
|
|
| 12 |
|
| 13 |
resized_shape = (768, 768, 3)
|
| 14 |
IMG_SCALING = (1, 1)
|
|
|
|
| 47 |
seg_model = keras.models.load_model('seg_unet_model.h5', custom_objects={'Combo_loss': Combo_loss, 'dice_coef': dice_coef})
|
| 48 |
|
| 49 |
# inputs = gr.inputs.Image(type="pil", label="Upload an image")
|
| 50 |
+
# image_output = gr.outputs.Image(type="pil", label="Output Image")
|
| 51 |
# outputs = gr.outputs.HTML() #uncomment for single class output
|
| 52 |
|
| 53 |
rows = 1
|
|
|
|
| 66 |
pred = np.squeeze(pred, axis=0)
|
| 67 |
fig = plt.figure(figsize=(10, 7))
|
| 68 |
fig.add_subplot(rows, columns, 1)
|
| 69 |
+
# plt.imshow(pred, interpolation='catrom')
|
| 70 |
+
plt.imshow(pred)
|
| 71 |
plt.axis('off')
|
|
|
|
| 72 |
plt.show()
|
|
|
|
| 73 |
return fig
|
| 74 |
|
| 75 |
title = "<h1 style='text-align: center;'>Semantic Segmentation</h1>"
|
| 76 |
description = "Upload an image and get prediction mask"
|
|
|
|
| 77 |
|
| 78 |
gr.Interface(fn=gen_pred,
|
| 79 |
inputs=[gr.Image(type='pil')],
|