Commit
·
788853f
1
Parent(s):
d0e2888
Update app.py
Browse files
app.py
CHANGED
@@ -25,7 +25,15 @@ def predict_segmentation(img):
|
|
25 |
resized_img = cv2.resize(gray_img, im_size)
|
26 |
# Predict the segmentation mask
|
27 |
pred = learn.predict(resized_img)
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
return output_image
|
30 |
|
31 |
input_image = gr.inputs.Image()
|
|
|
25 |
resized_img = cv2.resize(gray_img, im_size)
|
26 |
# Predict the segmentation mask
|
27 |
pred = learn.predict(resized_img)
|
28 |
+
import matplotlib.pyplot as plt
|
29 |
+
from PIL import Image
|
30 |
+
fig, ax = plt.subplots()
|
31 |
+
ax.imshow(pred[0], cmap='gray')
|
32 |
+
ax.axis('off')
|
33 |
+
fig.canvas.draw()
|
34 |
+
data = np.frombuffer(fig.canvas.tostring_rgb(), dtype=np.uint8)
|
35 |
+
data = data.reshape(fig.canvas.get_width_height()[::-1] + (3,))
|
36 |
+
output_image = Image.fromarray(data)
|
37 |
return output_image
|
38 |
|
39 |
input_image = gr.inputs.Image()
|