Commit
·
d64c0c1
1
Parent(s):
788853f
Update app.py
Browse files
app.py
CHANGED
@@ -25,15 +25,8 @@ 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 |
-
|
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()
|
|
|
25 |
resized_img = cv2.resize(gray_img, im_size)
|
26 |
# Predict the segmentation mask
|
27 |
pred = learn.predict(resized_img)
|
28 |
+
scaled_pred = (pred[0] * 255).astype(np.uint8)
|
29 |
+
output_image = PILImage.create(scaled_pred)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
return output_image
|
31 |
|
32 |
input_image = gr.inputs.Image()
|