示例#1
0
    def __init__(self, args):
        self.test_config = TestConfig.load_from_file(args.tests)
        self.classifier_config = Config.load_from_file(args.classify_config)
        model_file = self.classifier_config.classify.model
        if args.model_file:
            model_file = args.model_file

        path, ext = os.path.splitext(model_file)
        keras_model = False
        if ext == ".pb":
            keras_model = True
        self.clip_classifier = ClipClassifier(
            self.classifier_config,
            self.classifier_config.classify_tracking,
            model_file,
            keras_model,
        )
        # try download missing tests
        if args.user and args.password:
            api = UserAPI(args.server, args.user, args.password)
            out_dir = Path(self.test_config.clip_dir)
            if not out_dir.exists():
                out_dir.mkdir()
            for test in self.test_config.recording_tests:
                filepath = out_dir / test.filename
                if not filepath.exists():
                    if iter_to_file(out_dir / test.filename,
                                    api.download_raw(test.rec_id)):
                        logging.info("Saved %s", filepath)
        self.results = []
示例#2
0
 def __init__(self, args):
     self.test_config = TestConfig.load_from_file(args.tests)
     self.classifier_config = Config.load_from_file(args.classify_config)
     if args.model_file:
         model_file = args.model_file
     self.track_extractor = TrackExtractor(self.classifier_config)
     # try download missing tests
     if args.user and args.password:
         api = UserAPI(args.server, args.user, args.password)
         out_dir = Path(self.test_config.clip_dir)
         if not out_dir.exists():
             out_dir.mkdir()
         for test in self.test_config.recording_tests:
             filepath = out_dir / test.filename
             if not filepath.exists():
                 if iter_to_file(
                     out_dir / test.filename, api.download_raw(test.rec_id)
                 ):
                     logging.info("Saved %s", filepath)
     self.results = []
示例#3
0
def main():
    args = parse_args()
    api = UserAPI(args.server, args.user, args.password)
    out_dir = Path(args.out_folder)
    tests = []
    test_data = TestConfig(recording_tests=tests,
                           server=args.server,
                           clip_dir=args.out_folder)
    for rec_id in args.ids:
        rec_meta = api.get(rec_id)
        tracks = api.get_tracks(rec_id)
        filename = Path(rec_id).with_suffix(".cptv")
        fullpath = out_dir / filename
        tests.append(TestRecording.load_from_meta(rec_meta, tracks, filename))
        if not fullpath.exists():
            if iter_to_file(fullpath, api.download_raw(rec_id)):
                print("Saved {} - {}".format(rec_id, fullpath))
            else:
                print("error saving {}".format(rec_id))
    if os.path.exists(args.test_file):
        os.remove(args.test_file)
    with open(args.test_file, "w") as f:
        yaml.dump(test_data, f)