Computer vision RuntimeError:输入和输出大小应大于0,但获得了输入(H:1024,W:1)输出(H:800,W:0)

Computer vision RuntimeError:输入和输出大小应大于0,但获得了输入(H:1024,W:1)输出(H:800,W:0),computer-vision,pytorch,faster-rcnn,Computer Vision,Pytorch,Faster Rcnn,当我尝试按照官方教程对pytorcfaster rcnn进行微调时: 使用更宽的面数据集 我得到: RuntimeError:输入和输出大小应大于0,但获得了输入(H:1024,W:1)输出(H:800,W:0) 以下是我使用的Dataset getitem函数: def __getitem__(self,idx): img_path = self.imgs[idx] ann_path = self.anns[idx] img_id = self.

当我尝试按照官方教程对pytorcfaster rcnn进行微调时: 使用更宽的面数据集

我得到: RuntimeError:输入和输出大小应大于0,但获得了输入(H:1024,W:1)输出(H:800,W:0)

以下是我使用的Dataset getitem函数:

def __getitem__(self,idx):
        img_path = self.imgs[idx]
        ann_path = self.anns[idx]
        img_id = self.images_id[idx]

        img = Image.open(img_path).convert('RGB')
        img = np.asarray(img)
        img = img/255.0
        img = np.moveaxis(img,2,0)
        img = torch.from_numpy(img).float()

        boxes ,w,h= self.__extract_boxes__(ann_path)
        masks = np.zeros([h,w,len(boxes)],dtype='uint8')
        labels=list()
        for i in range (len(boxes)):
            box = boxes[i]
            
            row_s,row_e = box[1],box[3]
            col_s,col_e = box[0],box[2]

            masks[row_s:row_e,col_s:col_e,i]=1
            labels.append(1)
        

        boxes    = torch.as_tensor(boxes,dtype=torch.float32)
        masks    = torch.as_tensor(masks,dtype=torch.uint8)
        labels   = torch.ones((len(labels),),dtype=torch.int64)
        image_id = torch.tensor([idx])
        area     = (boxes[:, 3] - boxes[:, 1]) * (boxes[:, 2] - boxes[:, 0])
        
        target = {}
        target['boxes']=boxes
        target['labels'] = labels
        target['masks']=masks
        target['image_id']=image_id
        target['area']=area
        
        return img,target