How can i load coco caption data set using prebuilt tools?
<SCODE>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)
<ECODE> <SCODE>/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
<ECODE> Is there a simple way to install the coco api to solve this problem? Or, which directory should i clone the coco api repo?
yunjey
I have solved this problem by running make inside the coco/PythonAPI.  Still remaining problem is that i should run the code inside coco/PythonAPI, this is inconvenient. (from pycocotools.coco import COCO)
yunjey
Response777
Response777
Thanks for your reply. I am using Python 2.7.
yunjey

The first problem you came across is the same with https://github.com/pdollar/coco/issues/14 180, which is caused by forgetting make.(The cython was not compiled.)
 
The second problem is that this package is not in the path your python script would search in.

You may solve this running the setup.py in PythonAPI folder to copy this package to your pip folder.
Or you can add such code in your script```
import sys
sys.path.append(“The path of PythonAPI folder”)

 You may solve this running the setup.py in PythonAPI folder to copy this package to your pip folder. Or you can add such code in your script```
import sys
sys.path.append(“The path of PythonAPI folder”) <SCODE><ECODE>
Response777
Thank you very much! Your reply helped a lot.
yunjey
apaszke
It still fails for me. these are the following steps I took
Vyvian_Nellira