I want to load coco caption data set.
How can i install the coco caption api in here(https://github.com/pdollar/cocoa)?
What i want to do is to run the code below without causing an import error.
import torchvision.datasets as dset
import torchvision.transforms as transforms
cap = dset.CocoCaptions(root = '../data/train2014',
annFile = '../data/annotations/captions_train2014.json',
transform=transforms.ToTensor())
print('Number of samples: ', len(cap))
img, target = cap[3] # load 4th sample
print("Image Size: ", img.size())
print(target)
I have cloned the coco caption api repo to several directories. However, when i ran the code above, I got an import error such as ImportError: No module named pycocotools.coco
. To solve this problem, I ran the code above inside the coco/PythonAPI directory, but i received another import error as below.
/Users/yunjey/JupyterProjects/kwtl-pytorch/coco/PythonAPI/pycocotools/coco.py in <module>()
53 import copy
54 import itertools
---> 55 from . import mask as maskUtils
56 import os
57 from collections import defaultdict
/Users/yunjey/JupyterProjects/kwtl-pytorch/coco/PythonAPI/pycocotools/mask.py in <module>()
1 __author__ = 'tsungyi'
2
----> 3 import pycocotools._mask as _mask
4
5 # Interface for manipulating masks stored in RLE format.
ImportError: No module named _mask
Is there a simple way to install the coco api to solve this problem? Or, which directory should i clone the coco api repo?