Skip to content

Commit

Permalink
bug fix, coco fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kentaroy47 committed Dec 4, 2019
1 parent cb2e39a commit 0fff8b2
Show file tree
Hide file tree
Showing 8 changed files with 1,624 additions and 1,926 deletions.
10 changes: 5 additions & 5 deletions dataset/coco.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ def __call__(self, target, width, height):

return res # [[xmin, ymin, xmax, ymax, label_idx], ... ]


class COCODetection(data.Dataset):
"""`MS Coco Detection <http://mscoco.org/dataset/#detections-challenge2016>`_ Dataset.
Args:
Expand All @@ -85,7 +84,7 @@ class COCODetection(data.Dataset):
in the target (bbox) and transforms it.
"""

def __init__(self, root, image_set='trainval35k', transform=None,
def __init__(self, root, image_set='trainval35k', transform=None, phase="train",
target_transform=COCOAnnotationTransform(), dataset_name='MS COCO'):
sys.path.append(osp.join(root, COCO_API))
from pycocotools.coco import COCO
Expand All @@ -96,6 +95,7 @@ def __init__(self, root, image_set='trainval35k', transform=None,
self.transform = transform
self.target_transform = target_transform
self.name = dataset_name
self.phase = phase

def __getitem__(self, index):
"""
Expand Down Expand Up @@ -126,14 +126,14 @@ def pull_item(self, index):
target = self.coco.loadAnns(ann_ids)
path = osp.join(self.root, self.coco.loadImgs(img_id)[0]['file_name'])
assert osp.exists(path), 'Image path does not exist: {}'.format(path)
img = cv2.imread(osp.join(self.root, path))
#print(osp.join(self.root, path))
img = cv2.imread(path)
height, width, _ = img.shape
if self.target_transform is not None:
target = self.target_transform(target, width, height)
if self.transform is not None:
target = np.array(target)
img, boxes, labels = self.transform(img, target[:, :4],
target[:, 4])
img, boxes, labels = self.transform(img, self.phase, target[:, :4], target[:, 4])
# to rgb
img = img[:, :, (2, 1, 0)]

Expand Down
110 changes: 89 additions & 21 deletions effnet_testing.ipynb

Large diffs are not rendered by default.

Loading

0 comments on commit 0fff8b2

Please sign in to comment.