OmerFarooq commited on
Commit
3576575
1 Parent(s): 2f37c1e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -115,7 +115,7 @@ def gen_grad_img_single(grad_model, img, class_index, alpha = 0.4):
115
  return np.array(img).astype('uint8'), y_pred
116
 
117
 
118
- def gen_grad_both(grad_model, imgs, y_true, size, cols, font_size):
119
  img_c, y_pred_c = gen_grad_img_single(grad_model, imgs, 0)
120
  img_d, y_pred_d = gen_grad_img_single(grad_model, imgs, 1)
121
  y_pred_c = np.around(y_pred_c,3)
@@ -126,13 +126,14 @@ def gen_grad_both(grad_model, imgs, y_true, size, cols, font_size):
126
  if y_pred_c[0] > y_pred_c[1]: infer = "cat"
127
  else: infer = "dog"
128
 
129
- return [img_c, img_d], y_pred_c, infer
130
 
131
  weights = "weights.h5"
132
 
133
  def get_grad(img):
134
  img = img_pros(img)
135
- grad_imgs, y_pred, infer = gen_grad_img_single(weights, img)
 
136
  # pred_class = ""
137
  # if y_pred[0] > 0.5: pred_class = "cat"
138
  # else: pred_class = "dog"
 
115
  return np.array(img).astype('uint8'), y_pred
116
 
117
 
118
+ def gen_grad_both(grad_model, img):
119
  img_c, y_pred_c = gen_grad_img_single(grad_model, imgs, 0)
120
  img_d, y_pred_d = gen_grad_img_single(grad_model, imgs, 1)
121
  y_pred_c = np.around(y_pred_c,3)
 
126
  if y_pred_c[0] > y_pred_c[1]: infer = "cat"
127
  else: infer = "dog"
128
 
129
+ return img_c, img_d, y_pred_c, infer
130
 
131
  weights = "weights.h5"
132
 
133
  def get_grad(img):
134
  img = img_pros(img)
135
+ grad_model = create_grad_model(weights, 2, "softmax")
136
+ grad_imgs, y_pred, infer = gen_grad_both(grad_model, img)
137
  # pred_class = ""
138
  # if y_pred[0] > 0.5: pred_class = "cat"
139
  # else: pred_class = "dog"