def forward(ctx, image, boxes, box_ind, crop_height, crop_width, extrapolation_value=0): ctx.crop_height = crop_height ctx.crop_width = crop_width ctx.extrapolation_value = extrapolation_value crops = torch.zeros_like(image) if image.is_cuda: crop_and_resize_gpu.forward(image, boxes, box_ind, ctx.extrapolation_value, ctx.crop_height, ctx.crop_width, crops) else: crop_and_resize_cpu.forward(image, boxes, box_ind, ctx.extrapolation_value, ctx.crop_height, ctx.crop_width, crops) # save for backward ctx.im_size = image.size() ctx.save_for_backward(boxes, box_ind) return crops
def forward(self, image, boxes, box_ind): crops = torch.zeros_like(image) if image.is_cuda: crop_and_resize_gpu.forward( image, boxes, box_ind, self.extrapolation_value, self.crop_height, self.crop_width, crops) else: crop_and_resize_cpu.forward( image, boxes, box_ind, self.extrapolation_value, self.crop_height, self.crop_width, crops) # save for backward self.im_size = image.size() self.save_for_backward(boxes, box_ind) return crops