Commit
·
d453b08
1
Parent(s):
432e19c
Update app.py
Browse files
app.py
CHANGED
@@ -66,13 +66,13 @@ def gen_pred(img, model=seg_model):
|
|
66 |
pred = model.predict(img)
|
67 |
pred = np.squeeze(pred, axis=0)
|
68 |
# image = Image.fromarray(np.uint8(cm.plasma(pred)*255))
|
69 |
-
|
70 |
# im = Image.fromarray((pred * 255).astype(np.uint8))
|
71 |
# img_bytes = pred.tobytes()
|
72 |
# nparr = np.frombuffer(img_bytes, np.byte)
|
73 |
# pred_pil = cv2.imdecode(nparr, cv2.IMREAD_REDUCED_COLOR_8)
|
74 |
# return "UI in developing process ..."
|
75 |
-
return
|
76 |
|
77 |
title = "<h1 style='text-align: center;'>Semantic Segmentation</h1>"
|
78 |
description = "Upload an image and get prediction mask"
|
@@ -80,7 +80,7 @@ description = "Upload an image and get prediction mask"
|
|
80 |
|
81 |
gr.Interface(fn=gen_pred,
|
82 |
inputs=[gr.Image(type='numpy')],
|
83 |
-
outputs=gr.Image(type='
|
84 |
title=title,
|
85 |
examples=[["003e2c95d.jpg"], ["003b50a15.jpg"], ["003b48a9e.jpg"], ["0038cbe45.jpg"], ["00371aa92.jpg"]],
|
86 |
description=description,
|
|
|
66 |
pred = model.predict(img)
|
67 |
pred = np.squeeze(pred, axis=0)
|
68 |
# image = Image.fromarray(np.uint8(cm.plasma(pred)*255))
|
69 |
+
pil_img = Image.fromarray(pred, 'RGB')
|
70 |
# im = Image.fromarray((pred * 255).astype(np.uint8))
|
71 |
# img_bytes = pred.tobytes()
|
72 |
# nparr = np.frombuffer(img_bytes, np.byte)
|
73 |
# pred_pil = cv2.imdecode(nparr, cv2.IMREAD_REDUCED_COLOR_8)
|
74 |
# return "UI in developing process ..."
|
75 |
+
return pil_img
|
76 |
|
77 |
title = "<h1 style='text-align: center;'>Semantic Segmentation</h1>"
|
78 |
description = "Upload an image and get prediction mask"
|
|
|
80 |
|
81 |
gr.Interface(fn=gen_pred,
|
82 |
inputs=[gr.Image(type='numpy')],
|
83 |
+
outputs=gr.Image(type='pil'),
|
84 |
title=title,
|
85 |
examples=[["003e2c95d.jpg"], ["003b50a15.jpg"], ["003b48a9e.jpg"], ["0038cbe45.jpg"], ["00371aa92.jpg"]],
|
86 |
description=description,
|