Editing databunches

Hi

I am currently trying to train a UNET for image data segmentation.

My data has only one color channel (black and white), however the databunch has the rbg channels.

src = (SegmentationItemList.from_folder(path_img)
.split_by_rand_pct(valid_pct=0.2, seed=42)
.label_from_func(get_label_filenmes, classes=np.array([‘Present’,‘Absent’])))

data = (src.transform(get_transforms(), size=size, tfm_y=True)
.databunch(bs=bs)
.normalize(imagenet_stats))

Resulting in:
ImageDataBunch;

Train: LabelList (3200 items)
x: SegmentationItemList
Image (3, 50, 50),Image (3, 50, 50),Image (3, 50, 50),Image (3, 50, 50),Image (3, 50, 50)
y: SegmentationLabelList
ImageSegment (1, 50, 50),ImageSegment (1, 50, 50),ImageSegment (1, 50, 50),ImageSegment (1, 50, 50),ImageSegment (1, 50, 50)
Path: images;

Valid: LabelList (800 items)
x: SegmentationItemList
Image (3, 50, 50),Image (3, 50, 50),Image (3, 50, 50),Image (3, 50, 50),Image (3, 50, 50)
y: SegmentationLabelList
ImageSegment (1, 50, 50),ImageSegment (1, 50, 50),ImageSegment (1, 50, 50),ImageSegment (1, 50, 50),ImageSegment (1, 50, 50)
Path: images;

Test: None

I have 2 questions:

  1. How can I delete two of the 3 rgb channels. In the end I want two channels, where channel 1 is the black and white image and channel 2 is a transformed version of the image.

  2. Can I still use the resnet for normalization/transfer learning as it expects rbg inputs?

Thanks for the input,

Ray