-
-
Notifications
You must be signed in to change notification settings - Fork 387
Description
Environment Information
- samgeo version: 0.13.0
- Python version: 3.12.0
- Operating System: MacOS
Description
Im currently trying to get segmentation with boxes running. For that im going through the example on https://samgeo.gishub.org/examples/sam2_box_prompts/
My geoJson / m.user_rois looks like the following:
{'type': 'FeatureCollection',
'features': [{'type': 'Feature',
'properties': {},
'geometry': {'type': 'Polygon',
'coordinates': [[[7.575128, 51.961684],
[7.575128, 51.962253],
[7.576115, 51.962253],
[7.576115, 51.961684],
[7.575128, 51.961684]]]}}]}
When running "sam.predict(boxes=m.user_rois, point_crs="EPSG:4326", output="mask.tif", dtype="uint8")" i get the following exception:
`---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
Cell In[14], line 1
----> 1 sam.predict(
2 boxes=m.user_rois,
3 point_crs="EPSG:4326",
4 output="mask3.tif"
5 )
File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/samgeo/samgeo2.py:692, in SamGeo2.predict(self, point_coords, point_labels, boxes, mask_input, multimask_output, return_logits, normalize_coords, point_crs, output, index, mask_multiplier, dtype, return_results, **kwargs)
690 self.save_prediction(output, index, mask_multiplier, dtype, **kwargs)
691 else:
--> 692 self.tensor_to_numpy(
693 index, output, mask_multiplier, dtype, save_args=kwargs
694 )
696 if return_results:
697 return masks, scores, logits
File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/samgeo/samgeo2.py:1075, in SamGeo2.tensor_to_numpy(self, index, output, mask_multiplier, dtype, save_args)
1072 if index is None:
1073 index = 0
-> 1075 masks = masks[:, index, :, :]
1076 if len(masks.shape) == 4 and masks.shape[1] == 1:
1077 masks = masks.squeeze(1)
IndexError: too many indices for array: array is 3-dimensional, but 4 were indexed`
Who can help me here?
If you need any other information from me, dont hesitate to ask.
Thanks in advance!