Exemplo n.º 1
0
def load_mixture_set(setID, repetition, final_size):

    allRoidb = []
    annoCounts = []
    datasetSizes = cfg.MIXED_DATASET_SIZES
    if final_size not in datasetSizes:
        print("invalid dataset size")
        print("valid option sizes include:")
        print(datasetSizes)
        raise ValueError(
            "size {} is not in cfg.MIXED_DATASET_SIZES".format(final_size))
    sizeIndex = datasetSizes.index(final_size)
    prevSize = 0

    for size in datasetSizes[:sizeIndex + 1]:
        # create a file for each dataset size
        pklName = createFilenameID(setID, str(repetition), str(size)) + ".pkl"
        # write pickle file of the roidb
        if osp.exists(pklName) is True:
            fid = open(pklName, "rb")
            loaded = pickle.load(fid)
            roidbs = loaded['allRoidb']
            print(pklName)
            if size == final_size:  # only save the last count
                annoCounts = loaded['annoCounts']
            allRoidb.extend(roidbs)
            print_each_size(allRoidb)
            fid.close()
        else:
            raise ValueError("{} does not exists".format(pklName))
        prevSize += len(loaded)
    return allRoidb, annoCounts
Exemplo n.º 2
0
 def _load_mixture_roidb(self,repeat,size):
     """
     reads in the 
     """
     mixtureFile = createFilenameID(self.name,self.r,size)
     if osp.exists(mixtureFile) == False:
         raise KeyError("mixture {} doesn't exist.".format(mixtureFile))
     with open(mixtureFile, 'rb') as fid:
         roidb = pickle.load(fid)
     print('{} gt roidb loaded from {}'.format(self.name, mixtureFile))
     return roidb
Exemplo n.º 3
0
def load_mixture_set_single(setID, repetition, size):
    pklName = createFilenameID(setID, str(repetition), str(size)) + ".pkl"
    # write pickle file of the roidb
    if osp.exists(pklName) is True:
        fid = open(pklName, "rb")
        loaded = pickle.load(fid)
        allRoidb = loaded['allRoidb']
        annoCounts = loaded['annoCounts']
        print_each_size(allRoidb)
        fid.close()
    else:
        raise ValueError("{} does not exists".format(pklName))
    return allRoidb, annoCounts
Exemplo n.º 4
0
            # create setID folder
            path_setID = createPathSetID(setID)
            if osp.isdir(path_setID) == False:
                os.makedirs(path_setID)
            for r in range(repeat):
                # create the repeat folder
                path_repeat = createPathRepeat(setID, str(r))
                if osp.isdir(path_repeat) == False:
                    os.makedirs(path_repeat)
                # shuffle imdbs
                shuffle_imdbs()
                # reset previuos counters
                pc.zero()
                for size in datasetSizes:
                    # create a file for each dataset size
                    idlist_filename = createFilenameID(setID, str(r),
                                                       str(size))
                    repo_roidbs, roidbs_anno_counts = createMixtureDataset(
                        setID, size)
                    assert len(repo_roidbs) == setID.count('1')
                    # write pickle file of the roidb
                    allRoidb = combined_roidb(repo_roidbs)
                    onlyNewRoidb = combineOnlyNew(repo_roidbs, pc)
                    appendHOGtoRoidb(onlyNewRoidb)
                    pklName = idlist_filename + ".pkl"
                    print(pklName, roidbs_anno_counts, size)

                    pyroidb = RoidbDataset(allRoidb, [0, 1, 2, 3, 4, 5, 6, 7],
                                           loader=roidbSampleBox,
                                           transform=None)
                    printPyroidbSetCounts(pyroidb)
Exemplo n.º 5
0
def save_mixture_set_single(roidb, annoCount, setID, repetition, size):
    pklName = createFilenameID(setID, str(repetition), str(size)) + ".pkl"
    saveInfo = {"allRoidb": roidb, "annoCounts": annoCount}
    with open(pklName, "wb") as f:
        pickle.dump(saveInfo, f)