jbilcke-hf commited on
Commit
a84c111
·
1 Parent(s): 8846a66

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -551,20 +551,21 @@ def run_anything_task(input_image, text_prompt, box_threshold, text_threshold,
551
  assert sam_checkpoint, 'sam_checkpoint is not found!'
552
  # draw output image
553
  plt.figure(figsize=(10, 10))
 
554
  # plt.imshow(image)
555
  for mask in masks:
556
  show_mask(mask.cpu().numpy(), plt.gca(), random_color=True)
557
- for box, label in zip(boxes_filt, pred_phrases):
558
- show_box(box.cpu().numpy(), plt.gca(), label)
559
  plt.axis('off')
560
- image_path = os.path.join(output_dir, f"grounding_seg_output_{file_temp}.jpg")
561
  plt.savefig(image_path, bbox_inches="tight")
562
  segment_image_result = cv2.cvtColor(cv2.imread(image_path), cv2.COLOR_BGR2RGB)
563
  os.remove(image_path)
564
  output_images.append(segment_image_result)
565
 
566
  logger.info(f'run_anything_task_[{file_temp}]_{task_type}_9_')
567
- return output_images, gr.Gallery.update(label='result images')
568
 
569
  if __name__ == "__main__":
570
  parser = argparse.ArgumentParser("Grounded SAM demo", add_help=True)
 
551
  assert sam_checkpoint, 'sam_checkpoint is not found!'
552
  # draw output image
553
  plt.figure(figsize=(10, 10))
554
+ # we don't draw the background image
555
  # plt.imshow(image)
556
  for mask in masks:
557
  show_mask(mask.cpu().numpy(), plt.gca(), random_color=True)
558
+ # for box, label in zip(boxes_filt, pred_phrases):
559
+ # show_box(box.cpu().numpy(), plt.gca(), label)
560
  plt.axis('off')
561
+ image_path = os.path.join(output_dir, f"grounding_seg_output_{file_temp}.png")
562
  plt.savefig(image_path, bbox_inches="tight")
563
  segment_image_result = cv2.cvtColor(cv2.imread(image_path), cv2.COLOR_BGR2RGB)
564
  os.remove(image_path)
565
  output_images.append(segment_image_result)
566
 
567
  logger.info(f'run_anything_task_[{file_temp}]_{task_type}_9_')
568
+ return pred_dict, output_images, gr.Gallery.update(label='result images')
569
 
570
  if __name__ == "__main__":
571
  parser = argparse.ArgumentParser("Grounded SAM demo", add_help=True)