I have original defined name for VOC dataset , but I want to use folder structure as this:
––plant
——Images
———plant001_rgb.png
———plant002_rgb.png
——Masks
———plant001_label.png
———plant002_label.png
How should I make the change…I am so confusing, any help would be so glad
def getitem(self, index):
if index == 0:
shuffle(self.train_lines)
    annotation_line = self.train_lines[index]
    name = annotation_line.split()[0]

    jpg = Image.open(r"./VOCdevkit/VOC2007/JPEGImages" + '/' + name + ".jpg")
    png = Image.open(r"./VOCdevkit/VOC2007/SegmentationClass" + '/' + name + ".png")

    if self.random_data:
        jpg, png = self.get_random_data(jpg,png,(int(self.image_size[1]),int(self.image_size[0])))
    else:
        jpg, png = letterbox_image(jpg, png, (int(self.image_size[1]),int(self.image_size[0])))


    png = np.array(png)
    png[png >= self.num_classes] = self.num_classes
    
    seg_labels = np.eye(self.num_classes+1)[png.reshape([-1])]
    seg_labels = seg_labels.reshape((int(self.image_size[1]),int(self.image_size[0]),self.num_classes+1))
    jpg = np.transpose(np.array(jpg),[2,0,1])/255

    return jpg, png, seg_labels

51543×635 54.9 KB