etahamad commited on
Commit
04ddb18
1 Parent(s): cd153be

avoind edge cutting if didn't find any edges

Browse files
Files changed (1) hide show
  1. app.py +4 -0
app.py CHANGED
@@ -59,6 +59,9 @@ def edge_and_cut(img, threshold1, threshold2):
59
  if edges[i][j] != 0:
60
  edge_coors.append((i, j))
61
 
 
 
 
62
  row_min = edge_coors[np.argsort([coor[0] for coor in edge_coors])[0]][0]
63
  row_max = edge_coors[np.argsort([coor[0] for coor in edge_coors])[-1]][0]
64
  col_min = edge_coors[np.argsort([coor[1] for coor in edge_coors])[0]][1]
@@ -74,6 +77,7 @@ def edge_and_cut(img, threshold1, threshold2):
74
  return emb_img
75
 
76
 
 
77
  def classify_and_visualize(image):
78
  # Preprocess the image
79
  img_array = tf.image.resize(image, [256, 256])
 
59
  if edges[i][j] != 0:
60
  edge_coors.append((i, j))
61
 
62
+ if len(edge_coors) == 0:
63
+ return emb_img
64
+
65
  row_min = edge_coors[np.argsort([coor[0] for coor in edge_coors])[0]][0]
66
  row_max = edge_coors[np.argsort([coor[0] for coor in edge_coors])[-1]][0]
67
  col_min = edge_coors[np.argsort([coor[1] for coor in edge_coors])[0]][1]
 
77
  return emb_img
78
 
79
 
80
+
81
  def classify_and_visualize(image):
82
  # Preprocess the image
83
  img_array = tf.image.resize(image, [256, 256])