如何为segformer准备数据集?
我正在尝试训练Segformer进行一些医学图像,因此,按照微调教程尽可能接近 lnk 。
数据集由一些fMRI图像和要分割的特定病变组成,这些图像的大小
dataset = Dataset.from_dict({"image": img, 'label': mask}).cast_column("image", Image()).cast_column("label", Image())
dataset[0]
{'image': <PIL.PngImagePlugin.PngImageFile image mode=RGB size=562x471>,
'label': <PIL.PngImagePlugin.PngImageFile image mode=1 size=562x471>}
我尝试使用该功能的semantic_bitmap的
def convert_segmentation_bitmap(example):
return {
"label.segmentation_bitmap":
get_semantic_bitmap(
example["image"],
example["label"],
id_increment=0,
)
}
与 ?
原始fMRIS相同获得该图像的语义图是我所缺少的吗
谢谢
I'm trying to train a segformer for some medical images and therefore following the Fine tuning tutorial as close as possible lnk.
The dataset consists of some FMRI images and the specific lesion to segment out, these images are of the same size of the original FMRIs
dataset = Dataset.from_dict({"image": img, 'label': mask}).cast_column("image", Image()).cast_column("label", Image())
dataset[0]
{'image': <PIL.PngImagePlugin.PngImageFile image mode=RGB size=562x471>,
'label': <PIL.PngImagePlugin.PngImageFile image mode=1 size=562x471>}
I've tried to use get_semantic_bitmap from segments-ai.utils with this function
def convert_segmentation_bitmap(example):
return {
"label.segmentation_bitmap":
get_semantic_bitmap(
example["image"],
example["label"],
id_increment=0,
)
}
But this throws a TypeError Exception since PNG are not iterable
What am I missing to obtain the semantic map of this images?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的地面真相语义分割图应为2D阵列,其中包含每个像素的标签。这意味着,如果您将“标签”功能(类型映像)转换为numpy阵列,则获得一个2D数组:
这可能看起来如下:
这里有四个像素,其中三个被标记注释2和一个标签1注释。
Your ground truth semantic segmentation map should be a 2D array, that contains a label for each pixel. This means that if you would convert your "label" feature (which is of type Image) to a NumPy array, you obtain a 2D array:
This could look like the following:
Here we have four pixels, three of them being annotated with label 2 and one being annotated with label 1.