Exemple #1
0
    def save_pedestrians(self, pedestrians):
        train_pedestrians, val_pedestrians = ProcessData.save_pedestrians(
            self, pedestrians)

        def chunks(l, n):
            for i in xrange(0, len(l), n):
                yield l[i:i + n]

        for pedestrians, data_file_func in [
            (train_pedestrians, self.train_data_file),
            (val_pedestrians, self.val_data_file)
        ]:
            inputs = list(itertools.chain(*[p.inputs for p in pedestrians]))
            outputs = list(itertools.chain(*[p.outputs for p in pedestrians]))

            for i, (input_chunk, output_chunk) in enumerate(
                    zip(chunks(inputs, self.params['features_per_file']),
                        chunks(outputs, self.params['features_per_file']))):
                fname = data_file_func(i)
                features = [{
                    'fname':
                    ProcessDataNN._bytes_feature('{0}_{1}'.format(
                        os.path.splitext(os.path.basename(fname))[0], j)),
                    'input':
                    ProcessDataNN._floatlist_feature(np.ravel(input).tolist()),
                    'output':
                    ProcessDataNN._floatlist_feature(
                        np.ravel(output).tolist())
                } for j, (input,
                          output) in enumerate(zip(input_chunk, output_chunk))]

                self.save_tfrecord(fname, features)

        return train_pedestrians, val_pedestrians
Exemple #2
0
 def __init__(self, folder, params):
     ProcessData.__init__(self, folder, params)
Exemple #3
0
 def save_pedestrians(self, pedestrians):
     train_pedestrians, val_pedestrians = ProcessData.save_pedestrians(
         self, pedestrians)
     return train_pedestrians, val_pedestrians