-
-
Notifications
You must be signed in to change notification settings - Fork 351
Description
Hello, I'm ussing samgeo2 text prompt
I have a list of images that are going to be segmented one by one, the process runs fine, all the images meet the 8-bit RGB requirements.
The loop runs and sam.show_anns(cmap="Greys_r", add_boxes=False, alpha=1, blend=False, output=mask_output_filename) shows the segmented image:
But when saving the output it returns the error
TypeError: Cannot handle this data type: (1, 1), <i8
This is the entire error:
KeyError Traceback (most recent call last)
/usr/local/lib/python3.10/dist-packages/PIL/Image.py in fromarray(obj, mode)
3276 try:
-> 3277 mode, rawmode = _fromarray_typemap[typekey]
3278 except KeyError as e:
KeyError: ((1, 1), '<i8')
The above exception was the direct cause of the following exception:
TypeError Traceback (most recent call last)
4 frames
in <cell line: 14>()
75 # Procesar y segmentar el tile
76 tile_filename = process_tile(tile, transform, i, j)
---> 77 mask_output_filename = segment_image(tile_filename, output_dir)
78 output_masks.append(mask_output_filename)
79
in segment_image(tile_filename, output_dir)
53 title="Segmentación automatica",
54 )
---> 55 sam.show_anns(cmap="Greys_r", add_boxes=False, alpha=1, blend=False, output=mask_output_filename)
56
57 print(f"Segmentación y máscara guardada para {tile_filename}")
/usr/local/lib/python3.10/dist-packages/samgeo/text_sam.py in show_anns(self, figsize, axis, cmap, alpha, add_boxes, box_color, box_linewidth, title, output, blend, **kwargs)
569 plt.savefig(output, **kwargs)
570 else:
--> 571 array_to_image(self.prediction, output, self.source)
572
573 def raster_to_vector(self, image, output, simplify_tolerance=None, **kwargs):
/usr/local/lib/python3.10/dist-packages/samgeo/common.py in array_to_image(array, output, source, dtype, compress, **kwargs)
1525
1526 else:
-> 1527 img = Image.fromarray(array)
1528 img.save(output, **kwargs)
1529
/usr/local/lib/python3.10/dist-packages/PIL/Image.py in fromarray(obj, mode)
3279 typekey_shape, typestr = typekey
3280 msg = f"Cannot handle this data type: {typekey_shape}, {typestr}"
-> 3281 raise TypeError(msg) from e
3282 else:
3283 rawmode = mode
TypeError: Cannot handle this data type: (1, 1), <i8
The same thing happens if I add the output inside sam.predict
Any ideas, solutions, alternatives to save the result?
Curiously, if I pass the image one by one through the samgeo2 text prompt example, they work without any problem.