def main(): args = args_parse() cfg = config.Config(args.config) log.initLogger(args.logfile) db = RecDB(cfg.get_path('files', 'db'), args.dry_run) if args.action == 'get_names': print(db.get_names(args.file)) elif args.action == 'get_faces': print(db.get_faces(args.file)) elif args.action == 'print_details': db.print_details(args.file) elif args.action == 'print_stat': db.print_stat() elif args.action == 'get_folders': folders = db.get_folders() folders.sort() for f in folders: print(f) elif args.action == 'get_files': files = db.get_files(args.file) for f in files: print(f) elif args.action == 'find_files_by_names': files = db.find_files_by_names(args.names, args.file) for f in files: print(f) elif args.action == 'remove_file': db.remove(args.file) elif args.action == 'update_filepaths': db.update_filepaths(args.file, args.file)
def main(): args = args_parse() cfg = config.Config(args.config) log.initLogger(args.logfile) patt = patterns.createPatterns(cfg) patt.load() names = set([p['name'] for p in patt.persons()]) names.remove('trash') rdb = recdb.RecDB(cfg.get_path('files', 'db'), args.dry_run) pdb = plexdb.PlexDB(cfg.get_path('plex', 'db'), args.dry_run) pls = PlexSync( names, rdb, pdb, min_video_face_count=cfg['recognition']['min_video_face_count']) if args.action == 'set_tags': pls.set_tags(resync=args.resync) elif args.action == 'remove_tags': pls.remove_tags() elif args.action == 'sync_new': folders = cfg.get_path('plex', 'folders') pls.sync_new(cfg, patt, folders, ('.jpg', )) elif args.action == 'sync_deleted': folders = cfg.get_path('plex', 'folders') pls.sync_deleted(folders)
def main(): args = args_parse() cfg = config.Config(args.config) log.initLogger(args.logfile) if args.output and os.path.exists(args.output): shutil.rmtree(args.output) patt = patterns.createPatterns(cfg) patt.load() cachedb_file = cfg.get_path('files', 'cachedb') if cachedb_file: cdb = cachedb.CacheDB(cachedb_file) else: cdb = None tools.cuda_init(int(cfg['processing']['cuda_memory_limit'])) db = recdb.RecDB(cfg.get_path('files', 'db'), args.dry_run) rec = createRecognizer(patt, cfg, cdb, db) signal.signal(signal.SIGINT, lambda sig, frame: rec.stop()) if args.action == 'recognize_image': print(rec.recognize_image(args.input)[0]) elif args.action == 'recognize_video': print(rec.calc_names_in_video(rec.recognize_video(args.input)[0])) elif args.action == 'recognize_folder': rec.recognize_folder(args.input, args.output, args.reencode) elif args.action == 'remove_folder': rec.remove_folder(args.input) elif args.action == 'match_unmatched': rec.match({'type': 'unmatched'}, args.output, False) elif args.action == 'match_all': rec.match({'type': 'all'}, args.output, False) elif args.action == 'match_folder': rec.match({'type': 'folder', 'path': args.input}, args.output, True) elif args.action == 'clusterize_unmatched': rec.clusterize({'type': 'unmatched'}, args.output) elif args.action == 'save_faces': rec.save_faces({'type': 'folder', 'path': args.input}, args.output) elif args.action == 'get_faces_by_face': rec.get_faces_by_face(args.input, args.output)
def main(): args = args_parse() cfg = config.Config(args.config) log.initLogger(args.logfile) patt = createPatterns(cfg) if args.action == 'gen': patt.generate(args.regenerate) elif args.action == 'add': patt.load() patt.add_files(args.name, args.files) elif args.action == 'add_new': patt.load() patt.add_files(args.name, args.files, True) elif args.action == 'add_gen': patt.load() patt.add_files(args.name, args.files) patt.generate(args.regenerate) elif args.action == 'remove': patt.load() patt.remove_files(args.files) elif args.action == 'list': patt.load() for name, filename in zip(patt.names(), patt.files()): print(name, filename) elif args.action == 'persons': patt.load() for p in patt.persons(): print(p) elif args.action == 'optimize': patt.load() patt.optimize() elif args.action == 'analyze': patt.load() patt.analyze(args.print_out) elif args.action == 'set_landmarks': for f in args.files: tools.enable_landmarks(f, True) elif args.action == 'clear_landmarks': for f in args.files: tools.enable_landmarks(f, False)
def main(): args = args_parse() cfg = config.Config(args.config) if args.logfile: logfile = args.logfile else: logfile = cfg.get_path('server', 'log_file') log.initLogger(logfile) try: server = FaceRecServer(cfg) log.info("Face rec server up.") server.serve_forever() except KeyboardInterrupt: server.stop(False) server.status() server.server_close() log.info("Face rec server down.")