def run_video_frame_classification(train_dir):
    try:
        neg_dir = train_dir + '/0'
        pos_dir = train_dir + '/1'
        while 1:
            # Train using initial pos/neg
            c = vidfeat.SyntheticFrameFeature().train(vidfeat.load_label_frames(train_dir))
            # Predict on dataset
            hdfs_input = random.sample(hadoopy.ls('/user/brandyn/aladdin/mp4_devt/'), 96)
            start_time = '%f' % time.time()
            hdfs_output = '/user/brandyn/aladdin_results/video_grep/%s' % start_time
            picarus.vision.run_video_grep_frames(hdfs_input, hdfs_output, c)
            unsorted_dir = tempfile.mkdtemp()
            try:
                for _, y in hadoopy.readtb(hdfs_output):
                    open('%s/%s.jpg' % (unsorted_dir, hashlib.sha1(y).hexdigest()), 'w').write(y)
                # Present results to user and add to list
                try:
                    cmd = 'python -m interactive_learning.image_selector %s %s %s --port 8083' % (unsorted_dir, pos_dir, neg_dir)
                    print(cmd)
                    subprocess.call(cmd.split())
                except OSError:
                    pass
            finally:
                shutil.rmtree(unsorted_dir)
    finally:
        #shutil.rmtree(temp_root)
        pass
Exemple #2
0
def write_boxes():
    for label, frame in vidfeat.load_label_frames('/aladdin_data_cropped/person/'):
        if label == 1:  # Some of the people have a tiling artifact on the bottom
            frame = remove_tiling(frame)
        boxes = sample_boxes(frame.shape[:2])
        save_boxes('/aladdin_data_cropped/boxes/%d' % label, frame, boxes)
        print(label)
Exemple #3
0
def write_boxes():
    for label, frame in vidfeat.load_label_frames(
            '/aladdin_data_cropped/person/'):
        if label == 1:  # Some of the people have a tiling artifact on the bottom
            frame = remove_tiling(frame)
        boxes = sample_boxes(frame.shape[:2])
        save_boxes('/aladdin_data_cropped/boxes/%d' % label, frame, boxes)
        print(label)
Exemple #4
0
import vidfeat
import imfeat
import sklearn.svm


class VisibleLensFrameFeature(vidfeat.ClassifierFrameFeature):
    feature = imfeat.MetaFeature(imfeat.TinyImage())

    def __init__(self, *args, **kw):
        classifier = sklearn.svm.LinearSVC(class_weight='auto')
        super(VisibleLensFrameFeature, self).__init__(classifier=classifier,
                                                      *args, **kw)

    def _feature(self, image):
        return self.feature(image)


if __name__ == '__main__':
    data_root = '/home/brandyn/playground/visible_lens_data'
    c = VisibleLensFrameFeature().train(vidfeat.load_label_frames(data_root))
    vidfeat.save_to_py('models/visible_lens_frame_model0.py', classifier=c)