PhyscalX commited on
Commit
b36d09d
1 Parent(s): e07bb93

Add data guard for app

Browse files
Files changed (1) hide show
  1. app.py +2 -1
app.py CHANGED
@@ -180,7 +180,6 @@ def build_gradio_app(queues, command):
180
  poly = points[np.where(points[:, 2] <= 1)[0]][None, :, :]
181
  points = [lt, rb, poly] if len(lt) > 0 else [poly, np.array([[[0, 0, 4]]])]
182
  points = np.concatenate(points, axis=1)
183
- points = (np.array([[[0, 0, 4]]]) if len(points) == 0 else points).astype("float32")
184
  elif prompt == 1:
185
  img, points = mask_img["background"][:, :, (2, 1, 0)], []
186
  for layer in mask_img["layers"]:
@@ -191,6 +190,8 @@ def build_gradio_app(queues, command):
191
  points = np.pad(points, [(0, 0), (0, 0), (0, 1)], constant_values=1)
192
  pad_points = np.array([[[0, 0, 4]]], "float32").repeat(points.shape[0], 0)
193
  points = np.concatenate([points, pad_points], axis=1)
 
 
194
  inputs = {"img": img, "points": points}
195
  with command.output_index.get_lock():
196
  command.output_index.value += 1
 
180
  poly = points[np.where(points[:, 2] <= 1)[0]][None, :, :]
181
  points = [lt, rb, poly] if len(lt) > 0 else [poly, np.array([[[0, 0, 4]]])]
182
  points = np.concatenate(points, axis=1)
 
183
  elif prompt == 1:
184
  img, points = mask_img["background"][:, :, (2, 1, 0)], []
185
  for layer in mask_img["layers"]:
 
190
  points = np.pad(points, [(0, 0), (0, 0), (0, 1)], constant_values=1)
191
  pad_points = np.array([[[0, 0, 4]]], "float32").repeat(points.shape[0], 0)
192
  points = np.concatenate([points, pad_points], axis=1)
193
+ img = np.zeros((480, 640, 3), dtype="uint8") if img is None else img
194
+ points = (np.array([[[0, 0, 4]]]) if len(points) == 0 else points).astype("float32")
195
  inputs = {"img": img, "points": points}
196
  with command.output_index.get_lock():
197
  command.output_index.value += 1