示例#1
0
    def _setup_image_data(self):
        '''hdf5 image dataset'''
        extract_feats(self.opt)
        im = self.opt.get('image_mode')
        hdf5_path = self.image_path + 'mode_{}_noatt.hdf5'.format(im)
        hdf5_file = self.h5py.File(hdf5_path, 'r')
        self.image_dataset = hdf5_file['images']

        image_id_to_idx_path = self.image_path + 'mode_{}_id_to_idx.txt'.format(im)
        with open(image_id_to_idx_path, 'r') as f:
            self.image_id_to_idx = json.load(f)
    def _setup_image_data(self):
        """
        hdf5 image dataset.
        """
        extract_feats(self.opt)
        im = self.opt.get('image_mode')
        if self.opt.get('attention', False):
            hdf5_path = self.image_path + 'mode_{}.hdf5'.format(im)
        else:
            hdf5_path = self.image_path + 'mode_{}_noatt.hdf5'.format(im)
        hdf5_file = self.h5py.File(hdf5_path, 'r')
        self.image_dataset = hdf5_file['images']

        image_id_to_idx_path = self.image_path + 'mode_{}_id_to_idx.txt'.format(
            im)
        with open(image_id_to_idx_path, 'r') as f:
            self.image_id_to_idx = json.load(f)
#!/usr/bin/env python3

# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
Basic example which iterates through the tasks specified and load/extract the image
features.

For more documentation, use parlai.scripts.extract_image_feature.
"""
from parlai.scripts.extract_image_feature import setup_args, extract_feats

if __name__ == '__main__':
    parser = setup_args()
    opt = parser.parse_args()
    extract_feats(opt)