def get_roidb(imdb_name):
     #imdb = get_imdb(imdb_name)
     imdb = psdb(imdb_name)
     print('Loaded dataset `{:s}` for training'.format(imdb.name))
     imdb.set_proposal_method(cfg.TRAIN.PROPOSAL_METHOD)
     print('Set proposal method: {:s}'.format(cfg.TRAIN.PROPOSAL_METHOD))
     roidb = get_training_roidb(imdb)
     return roidb
def combined_roidb(imdb_names, training=True):
    """
  Combine multiple roidbs
  """
    def get_training_roidb(imdb):
        """Returns a roidb (Region of Interest database) for use in training."""
        if cfg.TRAIN.USE_FLIPPED:
            print('myself...:cfg.TRAIN.USE_FIPPED={0}'.format(
                cfg.TRAIN.USE_FLIPPED))  #True
            print('Appending horizontally-flipped training examples...')
            imdb.append_flipped_images()
            print('done')

        print('Preparing training data...')

        prepare_roidb(imdb)
        #ratio_index = rank_roidb_ratio(imdb)
        print('done')

        return imdb.roidb

    def get_roidb(imdb_name):
        #imdb = get_imdb(imdb_name)
        imdb = psdb(imdb_name)
        print('Loaded dataset `{:s}` for training'.format(imdb.name))
        imdb.set_proposal_method(cfg.TRAIN.PROPOSAL_METHOD)
        print('Set proposal method: {:s}'.format(cfg.TRAIN.PROPOSAL_METHOD))
        roidb = get_training_roidb(imdb)
        return roidb

    #roidbs = [get_roidb(s) for s in imdb_names.split('+')]
    roidbs = []
    for s in imdb_names.split('+'):
        print(s)
        roidbs.append(get_roidb(s))
    roidb = roidbs[0]

    # if len(roidbs) > 1:
    #   for r in roidbs[1:]:
    #     roidb.extend(r)
    #   tmp = get_imdb(imdb_names.split('+')[1])
    #   imdb = datasets.imdb.imdb(imdb_names, tmp.classes)
    # else:
    #   imdb = get_imdb(imdb_names)
    imdb = psdb('train')

    if training:
        roidb = filter_roidb(roidb)

    ratio_list, ratio_index = rank_roidb_ratio(roidb)

    return imdb, roidb, ratio_list, ratio_index
Exemple #3
0
                                    'Images.mat'))
        all_imgs = all_imgs['Img'].squeeze()
        all_imgs = [str(a[0][0]) for a in all_imgs]
        # training
        return list(set(all_imgs) - set(test))

    def _load_probes(self):
        """
        Load the list of (img, roi) for probes. For test split, it's defined
        by the protocol. For training split, will randomly choose some samples
        from the gallery as probes.
        """
        protoc = loadmat(
            osp.join(self._root_dir, 'annotation/test/train_test/TestG50.mat')
        )['TestG50'].squeeze()
        probes = []
        for item in protoc['Query']:
            im_name = osp.join(self._data_path, str(item['imname'][0, 0][0]))
            roi = item['idlocate'][0, 0][0].astype(np.int32)
            roi[2:] += roi[:2]
            probes.append((im_name, roi))
        return probes


if __name__ == '__main__':
    from datasets.psdb import psdb
    d = psdb('train')
    res = d.roidb
    from IPython import embed
    embed()
Exemple #4
0
from datasets.coco import coco
from datasets.psdb import psdb
import numpy as np

# Set up voc_<year>_<split> using selective search "fast" mode
for year in ['2007', '2012']:
    for split in ['train', 'val', 'trainval', 'test']:
        name = 'voc_{}_{}'.format(year, split)
        __sets[name] = (lambda split=split, year=year: pascal_voc(split, year))

# Set up coco_2014_<split>
for year in ['2014']:
    for split in ['train', 'val', 'minival', 'valminusminival']:
        name = 'coco_{}_{}'.format(year, split)
        __sets[name] = (lambda split=split, year=year: coco(split, year))

# Set up psdb_<split>
for split in ['train', 'test']:
    name = 'psdb_{}'.format(split)
    __sets[name] = (lambda split=split: psdb(split))

def get_imdb(name):
    """Get an imdb (image database) by name."""
    if not __sets.has_key(name):
        raise KeyError('Unknown dataset: {}'.format(name))
    return __sets[name]()

def list_imdbs():
    """List all registered imdbs."""
    return __sets.keys()
Exemple #5
0
for year in ['2015']:
    for split in ['train', 'val', 'trainval', 'test']:
        name = 'psdbUpperBody_{}_{}'.format(year, split)
        __sets[name] = (lambda split=split, year=year: psdbUpperBody(split, year))

# Set up psdbCrop_<year>_<split> using selective search "fast" mode
for year in ['2015']:
    for split in ['train', 'val', 'trainval', 'test', 'val1', 'val2']:
        name = 'psdbCrop_{}_{}'.format(year, split)
        __sets[name] = (lambda split=split, year=year: psdbCrop(split, year))

# Set up psdb_<year>_<split> using selective search "fast" mode
for year in ['2015']:
    for split in ['train', 'val', 'trainval', 'test']:
        name = 'psdb_{}_{}'.format(year, split)
        __sets[name] = (lambda split=split, year=year: psdb(split, year))


# Set up wider_<year>_<split> using selective search "fast" mode
for year in ['2015']:
    for split in ['train', 'val', 'trainval', 'test']:
        name = 'wider_{}_{}'.format(year, split)
        __sets[name] = (lambda split=split, year=year: wider(split, year))

# Set up aichal_<year>_<split> using selective search "fast" mode
for year in ['2017']:
    for split in ['train', 'val', 'trainval', 'test']:
        name = 'aichal_{}_{}'.format(year, split)
        __sets[name] = (lambda split=split, year=year: aichal(split, year))

Exemple #6
0
# Copyright (c) 2015 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Written by Ross Girshick
# --------------------------------------------------------
"""Factory method for easily getting imdbs by name."""

__sets = {}

from datasets.psdb import psdb
from datasets.pswdb import pswdb
import numpy as np

# Set up psdb_<split>
for split in ['train', 'test']:
    name = 'psdb_{}'.format(split)
    __sets[name] = (lambda split=split: psdb(split))

    # Set up pswdb_<split>
for split in ['train', 'test']:
    name = 'pswdb_{}'.format(split)
    __sets[name] = (lambda split=split: pswdb(split))


def get_imdb(name):
    """Get an imdb (image database) by name."""
    if not __sets.has_key(name):
        raise KeyError('Unknown dataset: {}'.format(name))
    return __sets[name]()


def list_imdbs():
Exemple #7
0
        if self._image_set == 'test': return test
        # all images
        all_imgs = loadmat(osp.join(self._root_dir, 'annotation', 'Images.mat'))
        all_imgs = all_imgs['Img'].squeeze()
        all_imgs = [str(a[0][0]) for a in all_imgs]
        # training
        return list(set(all_imgs) - set(test))

    def _load_probes(self):
        """
        Load the list of (img, roi) for probes. For test split, it's defined
        by the protocol. For training split, will randomly choose some samples
        from the gallery as probes.
        """
        protoc = loadmat(osp.join(self._root_dir,
            'annotation/test/train_test/TestG50.mat'))['TestG50'].squeeze()
        probes = []
        for item in protoc['Query']:
            im_name = osp.join(self._data_path, str(item['imname'][0,0][0]))
            roi = item['idlocate'][0,0][0].astype(np.int32)
            roi[2:] += roi[:2]
            probes.append((im_name, roi))
        return probes


if __name__ == '__main__':
    from datasets.psdb import psdb
    d = psdb('train')
    res = d.roidb
    from IPython import embed; embed()