Exemple #1
0
    def load_data(self):
        cfg = basic_config(self.newDir)

        if self.method == 'faster':
            cfg.faster_rcnn_config()
        elif self.method == 'fast':
            cfg.fast_rcnn_config()
        elif self.method == 'normal':
            cfg.rcnn_config()
        cfg = mcfg.rcnn_hoi_classes(cfg)
        cfg = set_config(cfg)
        cfg.get_args()
        cfg.dataset = 'HICO'
        cfg.update_paths()

        trainMeta = utils.load_dict(cfg.data_path + 'train')
        testMeta = utils.load_dict(cfg.data_path + 'test')

        trainGTMeta = utils.load_dict(cfg.data_path + 'train_GT')
        testGTMeta = utils.load_dict(cfg.data_path + 'test_GT')
        labels = utils.load_dict(cfg.data_path + 'labels')
        class_mapping = utils.load_dict(cfg.data_path + 'class_mapping')

        if cfg.max_classes is not None:
            # Reduce data to include only max_classes number of different classes
            _, counts = utils.getLabelStats(trainGTMeta, labels)
            reduced_idxs = utils.getReducedIdxs(counts, cfg.max_classes,
                                                labels)
            trainGTMeta = utils.reduceData(trainGTMeta, reduced_idxs)
            testGTMeta = utils.reduceData(testGTMeta, reduced_idxs)
            trainMeta = utils.reduceData(trainMeta, reduced_idxs)
            testMeta = utils.reduceData(testMeta, reduced_idxs)
            labels = utils.idxs2labels(reduced_idxs, labels)

        cfg.nb_classes = len(labels)
        cfg.set_class_weights(labels, trainGTMeta)
        _, valMeta = utils.splitData(list(trainMeta.keys()), trainMeta)
        self.cfg = cfg

        if cfg.move:
            self.move_data()

        print('Data:', cfg.data_path)
        print('Path:', cfg.my_results_path)

        self.labels = labels
        self.class_mapping = class_mapping
        self.trainMeta = trainMeta
        self.valMeta = valMeta
        self.testMeta = testMeta
        self.trainGTMeta = trainGTMeta
        self.testGTMeta = testGTMeta
Exemple #2
0
    def load_data(self):
        cfg = basic_config(self.newDir)
        cfg = set_config(cfg)
        cfg.get_args()
        cfg.update_paths()

        trainMeta = utils.load_dict(cfg.data_path + 'train')
        testMeta = utils.load_dict(cfg.data_path + 'test')

        trainGTMeta = utils.load_dict(cfg.data_path + 'train_GT')
        testGTMeta = utils.load_dict(cfg.data_path + 'test_GT')
        labels = utils.load_dict(cfg.data_path + 'labels')

        if cfg.max_classes is not None:
            # Reduce data to include only max_classes number of different classes
            _, counts = utils.getLabelStats(trainGTMeta, labels)
            trainGTMeta, reduced_idxs = utils.reduceTrainData(
                trainGTMeta, counts, cfg.max_classes)
            testGTMeta = utils.reduceTestData(testGTMeta, reduced_idxs)
            trainMeta = utils.reduceTestData(trainMeta, reduced_idxs)
            testMeta = utils.reduceTestData(testMeta, reduced_idxs)
            labels = utils.idxs2labels(reduced_idxs, labels)

        cfg.nb_classes = len(labels)
        cfg.set_class_weights(labels, trainGTMeta)
        _, valMeta = utils.splitData(list(trainMeta.keys()), trainMeta)
        self.cfg = cfg

        if cfg.move:
            self.move_data()

        print('Path:', cfg.my_results_path)

        self.labels = labels
        self.trainMeta = trainMeta
        self.valMeta = valMeta
        self.testMeta = testMeta
        self.trainGTMeta = trainGTMeta
        self.testGTMeta = testGTMeta
Exemple #3
0
        new_imagesMeta[imageID] = {
            'imageName': imageMeta['imageName'],
            'rels': rels
        }
    return new_imagesMeta

if __name__ == "__main__":
    #    metaData = sio.loadmat(url + 'anno.mat', struct_as_record=False, squeeze_me=True)
    bbData = sio.loadmat(url + 'anno_bbox.mat',
                         struct_as_record=False,
                         squeeze_me=True)
    #    actions = bbData['list_action']
    #    trainYMatrix = metaData['anno_train']
    bbDataTrain = bbData['bbox_train']
    cfg = basic_config()
    cfg = set_config(cfg)
    cfg.dataset = 'HICO'
    cfg.get_data_path()
    cfg.get_results_paths()
    labels = utils.load_dict(cfg.data_path + 'labels')
    print("Extract meta data")
    tmpTrainMeta = extractMetaData(bbDataTrain)
    print("Combine similar BBs")
    newTrainMeta = combineSimilarBBs(tmpTrainMeta, labels, 0.4)
    newTrainMetaID = list(newTrainMeta.keys())
    newTrainMetaID.sort()
    #    imagesID = imagesID[6490:7000]
    #    images = pp.loadImages(imagesID, imagesMeta, url+"images/train2015/")
    #    [dataXP, dataXB, dataY, dataMeta] = pp.getData(imagesID, imagesMeta, images, (224,244))
    #    trainYMatrix = pp.getMatrixLabels(len(actions), dataY)
    utils.save_dict(tmpTrainMeta, url + 'HICO_train_GT')