Whity
November 2, 2022, 11:15am
1
Hi
I would like to update my project from fastai v1 to v2 and especially to add the timm library.
I slowly work from cell to cell, I’m a low level hobbyist, and now I’m stuck with this:
images_with_macula = SegmentationItemList.from_folder(‘anatomie_png/images’).filter_by_func(lambda path: not (‘nomacula’ in str(path))).split_by_folder()
What’s the replacement for SegmentationItemList in v2?
Thank you for your help.
Christian
SegmentationDataLoaders
should be a replacement for SegmentationItemList
.
The computer vision tutorial in the documentation also covers semantic segmentation: fastai - Computer vision intro
1 Like
Whity
November 7, 2022, 5:47pm
3
Hi Marius
Thank you, I will have a look into it.
Whity
November 10, 2022, 2:19pm
4
Hi Marius
I really stuck here how to change the code from the following section to Version 2, maybe you could help me to get this thing work?
Original code:
images_with_macula = SegmentationItemList.from_folder('anatomie_png/images').filter_by_func(lambda path: not ('nomacula' in str(path))).split_by_folder()
from pathlib import PosixPath
def get_label(path_to_image):
return PosixPath('segmentations_png/segmentations')/path_to_image.parts[2]/path_to_image.parts[3]/path_to_image.parts[4]
codes = ['nomacula','macula']
labelled_images_with_macula = images_with_macula.label_from_func(get_label, classes=codes)
data = labelled_images_with_macula.transform(get_transforms(), size=224, resize_method = ResizeMethod.PAD, padding_mode='zeros', tfm_y=True).databunch(bs=4)
My try:
#path= get_files.from_folder('anatomie_png/images').filter_by_func(lambda path: not ('nomacula' in str(path))).split_by_folder()
from pathlib import PosixPath
def get_label(path_to_image):
return PosixPath('segmentations_png/segmentations')/path_to_image.parts[2]/path_to_image.parts[3]/path_to_image.parts[4]
fnames = get_image_files(path)
codes = ['nomacula','macula']
data = SegmentationDataLoaders.from_label_func(path, fnames, label_func=get_label, codes=codes)
Thank you!
Sorry, actually I don’t really understand your code example. What error do you get? do you get any error?
How exactly is your data structured?
Could you maybe give a more throughout example?
Did you read the tutorial on semantic segmentation in the docs? fastai - Computer vision intro
1 Like