yuragoithf commited on
Commit
071957e
·
1 Parent(s): 52deca6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -70,13 +70,14 @@ def gen_pred(img=inputs, model=seg_model):
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"
 
70
  pred = model.predict(img)
71
  pred = np.squeeze(pred, axis=0)
72
  print(pred)
73
+ img_bytes = pred.tobytes()
74
+ nparr = np.frombuffer(img_bytes, np.byte)
75
+ pred_pil = cv2.imdecode(nparr, cv2.IMREAD_REDUCED_COLOR_8)
76
  # color_coverted = cv2.cvtColor(pred, cv2.COLOR_BGR2RGB)
77
  # pil_image = Image.fromarray(pred)
78
  # PIL_image = Image.fromarray(pred.astype('uint8'), 'RGB')
79
  # return "UI in developing process ..."
80
+ return pred_pil
81
 
82
  title = "<h1 style='text-align: center;'>Semantic Segmentation</h1>"
83
  description = "Upload an image and get prediction mask"