未验证 提交 ebdd88b4 编写于 作者: H Hao Chen 提交者: GitHub

Merge pull request #164 from stanstarks/master

Make compatible with torchvision 0.4.0
......@@ -61,7 +61,7 @@ class COCODataset(torchvision.datasets.coco.CocoDetection):
v: k for k, v in self.json_category_id_to_contiguous_id.items()
}
self.id_to_img_map = {k: v for k, v in enumerate(self.ids)}
self.transforms = transforms
self._transforms = transforms
def __getitem__(self, idx):
img, anno = super(COCODataset, self).__getitem__(idx)
......@@ -90,8 +90,8 @@ class COCODataset(torchvision.datasets.coco.CocoDetection):
target = target.clip_to_image(remove_empty=True)
if self.transforms is not None:
img, target = self.transforms(img, target)
if self._transforms is not None:
img, target = self._transforms(img, target)
return img, target, idx
......
......@@ -16,8 +16,6 @@ def do_voc_evaluation(dataset, predictions, output_folder, logger):
gt_boxlists = []
for image_id, prediction in enumerate(predictions):
img_info = dataset.get_img_info(image_id)
if len(prediction) == 0:
continue
image_width = img_info["width"]
image_height = img_info["height"]
prediction = prediction.resize((image_width, image_height))
......
......@@ -57,9 +57,12 @@ class Resize(object):
def __call__(self, image, target=None):
size = self.get_size(image.size)
image = F.resize(image, size)
if target is None:
if isinstance(target, list):
target = [t.resize(image.size) for t in target]
elif target is None:
return image
target = target.resize(image.size)
else:
target = target.resize(image.size)
return image, target
......
import cv2
import copy
import torch
import numpy as np
from fcos_core.layers.misc import interpolate
......@@ -195,7 +195,7 @@ class PolygonInstance(object):
polygons = valid_polygons
elif isinstance(polygons, PolygonInstance):
polygons = [p.clone() for p in polygons.polygons]
polygons = copy.copy(polygons.polygons)
else:
RuntimeError(
"Type of argument `polygons` is not allowed:%s" % (type(polygons))
......@@ -414,7 +414,8 @@ class PolygonList(object):
else:
# advanced indexing on a single dimension
selected_polygons = []
if isinstance(item, torch.Tensor) and item.dtype == torch.uint8:
if isinstance(item, torch.Tensor) and \
item.dtype == torch.uint8 or item.dtype == torch.bool:
item = item.nonzero()
item = item.squeeze(1) if item.numel() > 0 else item
item = item.tolist()
......@@ -522,7 +523,9 @@ class SegmentationMask(object):
next_segmentation = self.__getitem__(self.iter_idx)
self.iter_idx += 1
return next_segmentation
raise StopIteration
raise StopIteration()
next = __next__ # Python 2 compatibility
def __repr__(self):
s = self.__class__.__name__ + "("
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册