Commit
·
2f3365b
1
Parent(s):
c0ca22c
Update app.py
Browse files
app.py
CHANGED
@@ -56,14 +56,9 @@ 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
|
60 |
-
|
61 |
-
|
62 |
-
buf = io.BytesIO()
|
63 |
-
fig.savefig(buf)
|
64 |
-
buf.seek(0)
|
65 |
-
img = Image.open(buf)
|
66 |
-
return img
|
67 |
|
68 |
|
69 |
def gen_pred(img=inputs, model=seg_model):
|
@@ -79,7 +74,7 @@ def gen_pred(img=inputs, model=seg_model):
|
|
79 |
pred = model.predict(img)
|
80 |
pred = np.squeeze(pred, axis=0)
|
81 |
print(pred)
|
82 |
-
pred =
|
83 |
# color_coverted = cv2.cvtColor(pred, cv2.COLOR_BGR2RGB)
|
84 |
# pil_image = Image.fromarray(pred)
|
85 |
# PIL_image = Image.fromarray(pred.astype('uint8'), 'RGB')
|
|
|
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):
|
|
|
74 |
pred = model.predict(img)
|
75 |
pred = np.squeeze(pred, axis=0)
|
76 |
print(pred)
|
77 |
+
pred = convert_from_cv2_to_image(pred)
|
78 |
# color_coverted = cv2.cvtColor(pred, cv2.COLOR_BGR2RGB)
|
79 |
# pil_image = Image.fromarray(pred)
|
80 |
# PIL_image = Image.fromarray(pred.astype('uint8'), 'RGB')
|