Commit
·
52deca6
1
Parent(s):
2f3365b
Update app.py
Browse files
app.py
CHANGED
@@ -56,10 +56,6 @@ inputs = gr.inputs.Image(type="pil", label="Upload an image", source="upload")
|
|
56 |
image_output = gr.outputs.Image(type="numpy", label="Output Image")
|
57 |
# outputs = gr.outputs.HTML() #uncomment for single class output
|
58 |
|
59 |
-
def convert_from_cv2_to_image(img: np.ndarray) -> Image:
|
60 |
-
# return Image.fromarray(img)
|
61 |
-
return Image.fromarray(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))
|
62 |
-
|
63 |
|
64 |
def gen_pred(img=inputs, model=seg_model):
|
65 |
# rgb_path = os.path.join(test_image_dir,img)
|
@@ -74,12 +70,13 @@ def gen_pred(img=inputs, model=seg_model):
|
|
74 |
pred = model.predict(img)
|
75 |
pred = np.squeeze(pred, axis=0)
|
76 |
print(pred)
|
77 |
-
|
|
|
78 |
# color_coverted = cv2.cvtColor(pred, cv2.COLOR_BGR2RGB)
|
79 |
# pil_image = Image.fromarray(pred)
|
80 |
# PIL_image = Image.fromarray(pred.astype('uint8'), 'RGB')
|
81 |
# return "UI in developing process ..."
|
82 |
-
return
|
83 |
|
84 |
title = "<h1 style='text-align: center;'>Semantic Segmentation</h1>"
|
85 |
description = "Upload an image and get prediction mask"
|
|
|
56 |
image_output = gr.outputs.Image(type="numpy", label="Output Image")
|
57 |
# outputs = gr.outputs.HTML() #uncomment for single class output
|
58 |
|
|
|
|
|
|
|
|
|
59 |
|
60 |
def gen_pred(img=inputs, model=seg_model):
|
61 |
# rgb_path = os.path.join(test_image_dir,img)
|
|
|
70 |
pred = model.predict(img)
|
71 |
pred = np.squeeze(pred, axis=0)
|
72 |
print(pred)
|
73 |
+
cv2_img = cv2.cvtColor(pred, cv2.COLOR_BGR2RGB)
|
74 |
+
pil_img = Image.fromarray(cv2_img)
|
75 |
# color_coverted = cv2.cvtColor(pred, cv2.COLOR_BGR2RGB)
|
76 |
# pil_image = Image.fromarray(pred)
|
77 |
# PIL_image = Image.fromarray(pred.astype('uint8'), 'RGB')
|
78 |
# return "UI in developing process ..."
|
79 |
+
return pil_img
|
80 |
|
81 |
title = "<h1 style='text-align: center;'>Semantic Segmentation</h1>"
|
82 |
description = "Upload an image and get prediction mask"
|