vahidrezanezhad commited on
Commit
533cad9
1 Parent(s): 6f5ee08

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -6
app.py CHANGED
@@ -38,12 +38,18 @@ def visualize_model_output(prediction, img):
38
  output[:,:,1][prediction[:,:,0]==unq_class] = rgb_class_unique[1]
39
  output[:,:,2][prediction[:,:,0]==unq_class] = rgb_class_unique[2]
40
 
41
- output = output.astype(np.float64)
42
- img = img.astype(np.float64)
43
-
44
- overlayed_image = cv2.addWeighted(img,0.4,output,0.1,0)
45
-
46
- return overlayed_image.astype(np.uint8)
 
 
 
 
 
 
47
 
48
 
49
  def do_prediction(model_name, img):
 
38
  output[:,:,1][prediction[:,:,0]==unq_class] = rgb_class_unique[1]
39
  output[:,:,2][prediction[:,:,0]==unq_class] = rgb_class_unique[2]
40
 
41
+ output = output.astype(np.int8)
42
+ img = img.astype(np.int8)
43
+
44
+ bg_img = img.copy()
45
+ shapes = np.zeros_like(img, np.uint8)
46
+ shapes = output
47
+ mask = shapes.astype(bool)
48
+ alpha = 0.2
49
+ bg_img[mask] = cv2.addWeighted(bg_img, 1 - alpha, shapes, alpha, 0)[mask]
50
+
51
+
52
+ return bg_img
53
 
54
 
55
  def do_prediction(model_name, img):