The change on name definition...Help

I have original defined name for VOC dataset , but I want to use folder structure as this:

How should I make the change…I am so confusing, any help would be so glad

def getitem(self, index):
if index == 0:

    annotation_line = self.train_lines[index]
    name = annotation_line.split()[0]

    jpg ="./VOCdevkit/VOC2007/JPEGImages" + '/' + name + ".jpg")
    png ="./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])))
        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