derektan commited on
Commit
4adc5da
·
1 Parent(s): bf0e87f

Updated error images to black

Browse files
Files changed (1) hide show
  1. app.py +10 -10
app.py CHANGED
@@ -159,19 +159,19 @@ model.eval()
159
  examples = [
160
  [
161
  "Where can the driver see the car speed in this image? Please output segmentation mask.",
162
- "./resources/imgs/example1.jpg",
163
  ],
164
  [
165
  "Can you segment the food that tastes spicy and hot?",
166
- "./resources/imgs/example2.jpg",
167
  ],
168
  [
169
  "Assuming you are an autonomous driving robot, what part of the diagram would you manipulate to control the direction of travel? Please output segmentation mask and explain why.",
170
- "./resources/imgs/example1.jpg",
171
  ],
172
  [
173
  "What can make the woman stand higher? Please output segmentation mask and explain why.",
174
- "./resources/imgs/example3.jpg",
175
  ],
176
  ]
177
  output_labels = ["Segmentation Output"]
@@ -214,10 +214,10 @@ def inference(input_str, input_image):
214
 
215
  ## input valid check
216
  if not re.match(r"^[A-Za-z ,.!?\'\"]+$", input_str) or len(input_str) < 1:
217
- output_str = "[Error] Invalid input: ", input_str
218
- # output_image = np.zeros((128, 128, 3))
219
- ## error happened
220
- output_image = cv2.imread("./resources/error_happened.png")[:, :, ::-1]
221
  return output_image, output_str
222
 
223
  # Model Inference
@@ -334,8 +334,8 @@ def inference(input_str, input_image):
334
  if save_img is not None:
335
  output_image = save_img # input_image
336
  else:
337
- ## no seg output
338
- output_image = cv2.imread("./resources/no_seg_out.png")[:, :, ::-1]
339
  return output_image, output_str
340
 
341
 
 
159
  examples = [
160
  [
161
  "Where can the driver see the car speed in this image? Please output segmentation mask.",
162
+ "./imgs/example1.jpg",
163
  ],
164
  [
165
  "Can you segment the food that tastes spicy and hot?",
166
+ "./imgs/example2.jpg",
167
  ],
168
  [
169
  "Assuming you are an autonomous driving robot, what part of the diagram would you manipulate to control the direction of travel? Please output segmentation mask and explain why.",
170
+ "./imgs/example1.jpg",
171
  ],
172
  [
173
  "What can make the woman stand higher? Please output segmentation mask and explain why.",
174
+ "./imgs/stand_higher.jpg",
175
  ],
176
  ]
177
  output_labels = ["Segmentation Output"]
 
214
 
215
  ## input valid check
216
  if not re.match(r"^[A-Za-z ,.!?\'\"]+$", input_str) or len(input_str) < 1:
217
+ output_str = f"[Error] Invalid input: {input_str}"
218
+ # Create a red placeholder image to indicate an error
219
+ output_image = np.zeros((128, 128, 3), dtype=np.uint8)
220
+ output_image[:] = (0, 0, 0) # Red color in RGB
221
  return output_image, output_str
222
 
223
  # Model Inference
 
334
  if save_img is not None:
335
  output_image = save_img # input_image
336
  else:
337
+ ## no segmentation output, return a black placeholder image
338
+ output_image = np.zeros((128, 128, 3), dtype=np.uint8)
339
  return output_image, output_str
340
 
341