datasets.py 文件源码

python
阅读 35 收藏 0 点赞 0 评论 0

项目:RetinaNet 作者: c0nn3r 项目源码 文件源码
def __getitem__(self, index):
        """
        Args:
            index (int): Index
        Returns:
            tuple: Tuple (image, target). target is the object returned by ``coco.loadAnns``.
        """
        coco = self.coco
        img_id = self.ids[index]
        ann_ids = coco.getAnnIds(imgIds=img_id)
        target = coco.loadAnns(ann_ids)

        target = torch.unsqueeze(torch.Tensor(target[0]['bbox']), -1)

        path = coco.loadImgs(img_id)[0]['file_name']

        img = Image.open(os.path.join(self.root, path)).convert('RGB')

        if self.transform is not None:
            img = self.transform(img)

        if self.target_transform is not None:
            target = self.target_transform(target)

        return img, target
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号