CAMMA-public / cholect50

A repository for surgical action triplet dataset. Data are videos of laparoscopic cholecystectomy that have been annotated with <instrument, verb, target> labels for every surgical fine-grained activity.
Other
42 stars 4 forks source link

No definition for self.triplet_labels #3

Closed csEylLee closed 1 year ago

csEylLee commented 1 year ago

https://github.com/CAMMA-public/cholect50/blob/8c6ef05833ab01d6d8604a4f925f496ed1eae672/dataloader_pth.py#L192

Hello, there is the definition of "self.triplet_labels" in dataloader.py of RDV's code. But there is no definition in dataloader_pth.py of this repository. I have tried to define it, could you please help me to see if it is correct?

After I defined it, I trained RDV with dataloader_pth.py, but there was a strange phenomenon: when I set the batchsize=8, the training took only a dozen seconds per epoch on a Nvidia Titan Xp. Do you know what caused this?


class T50(Dataset):  
    def __init__(self, img_dir, label_file, transform=None, target_transform=None):
        label_data = json.load(open(label_file, "rb"))
        self.label_data = label_data["annotations"]
        self.frames = self.label_data.keys()
        self.img_dir = img_dir
        self.transform = transform
        self.target_transform = target_transform
        self.triplet_labels = self.get_triplets_labels_num(self.label_data)
    def get_triplets_labels_num(self, label):
        num_triplets = 0
        for i in self.frames:
            single_frame_anno = label[i]
            num_triplets = num_triplets + len(single_frame_anno)
            return num_triplets
    def __len__(self):
        return self.triplet_labels```
csEylLee commented 1 year ago

Oh, I had a logical error and now I have solved it. It's so embarrassing.