Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

why? results_insights, sam_inferred_masks = segment_images_and_measure_results(mask_predictor, yolo_infered_bboxes_in_voc_format, ATA_SUBDIR, GENERIC_ANNOTATIONS_FILE_NAME, SEGMENTATION_PREDICTION_SAVING_DIR) #1

Open
threeneedone opened this issue Jun 14, 2023 · 0 comments

Comments

@threeneedone
Copy link

DATA_SUBDIR = f"{HOME}/data/test"
SEGMENTATION_PREDICTION_SAVING_DIR = f"{DATA_SUBDIR}/segmented_images"
if not os.path.isdir(SEGMENTATION_PREDICTION_SAVING_DIR):
os.mkdir(SEGMENTATION_PREDICTION_SAVING_DIR)

Sometimes needed because of a bug in SAM

torch.use_deterministic_algorithms(mode=True, warn_only=True)

mask_predictor = SamPredictor(sam)

results_insights, sam_inferred_masks = segment_images_and_measure_results(mask_predictor, yolo_infered_bboxes_in_voc_format, DATA_SUBDIR, GENERIC_ANNOTATIONS_FILE_NAME, SEGMENTATION_PREDICTION_SAVING_DIR)

0%
0/16 [00:02<?, ?it/s]

ValueError Traceback (most recent call last)
in <cell line: 11>()
9 mask_predictor = SamPredictor(sam)
10
---> 11 results_insights, sam_inferred_masks = segment_images_and_measure_results(mask_predictor, yolo_infered_bboxes_in_voc_format,
12 DATA_SUBDIR, GENERIC_ANNOTATIONS_FILE_NAME,
13 SEGMENTATION_PREDICTION_SAVING_DIR)

1 frames
/content/SOTA_YOLOv8_and_SAM/save_and_display_image.py in save_overlayed_image(images_path, image_name, saving_dir, bboxes, masks, alpha, format, BGR_color_bboxes, BGR_color_masks, image_size)
147 if bboxes:
148 image = overlay_image_with_bboxes(image, bboxes, format=format, BGR_color=BGR_color_bboxes, image_size=image_size)
--> 149 if masks:
150 image = overlay_image_with_masks(image, masks, BGR_color=BGR_color_masks, alpha=alpha)
151 cv2.imwrite(f"{saving_dir}/{image_name[:-4]}-segmented.jpg", image)

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant