def prepare_models(root_dir: str = '/models'): backend_name = os.getenv('INFERENCE_BACKEND', 'trt') rec_name = os.getenv("REC_NAME", "arcface_r100_v1") rec_batch_size = int(os.getenv("REC_BATCH_SIZE", 1)) det_name = os.getenv("DET_NAME", "retinaface_mnet025_v2") ga_name = os.getenv("GA_NAME", "genderage_v1") force_fp16 = tobool(os.getenv('FORCE_FP16', True)) #False max_size = parse_size(os.getenv('MAX_SIZE')) if max_size is None: max_size = [640, 640] config = Configs(models_dir=root_dir) for model in [rec_name, det_name, ga_name]: batch_size = 1 if model in [ 'arcface_r100_v1', 'r50-arcface-msfdrop75', 'r100-arcface-msfdrop75', 'glint360k_r100FC_1.0', 'glint360k_r100FC_0.1' ]: batch_size = rec_batch_size logging.info(f"Preparing '{model}' model...") prepare_backend(model_name=model, backend_name=backend_name, im_size=max_size, force_fp16=force_fp16, max_batch_size=batch_size, config=config)
def __init__(self): # Global parameters self.threshold = float(os.getenv('DET_THRESH', 0.6)) self.max_size = parse_size(os.getenv('MAX_SIZE')) self.return_face_data = tobool(os.getenv('DEF_RETURN_FACE_DATA', False)) self.extract_embedding = tobool( os.getenv('DEF_EXTRACT_EMBEDDING', True)) self.extract_ga = tobool(os.getenv('DEF_EXTRACT_GA', False)) self.api_ver = os.getenv('DEF_API_VER', "1")
device = os.environ.get("DEVICE", 'cuda') rec_name = os.environ.get("REC_NAME", "arcface_r100_v1") det_name = os.environ.get("DET_NAME", "retinaface_mnet025_v2") ga_name = os.environ.get("GA_NAME", "genderage_v1") ga_ignore = tobool(os.environ.get('GA_IGNORE', False)) rec_ignore = tobool(os.environ.get('REC_IGNORE', False)) if rec_ignore: rec_name = None if ga_ignore: ga_name = None # Global parameters max_size = parse_size(os.environ.get('MAX_SIZE')) return_face_data = tobool(os.environ.get('DEF_RETURN_FACE_DATA', False)) extract_embedding = tobool(os.environ.get('DEF_EXTRACT_EMBEDDING', True)) extract_ga = tobool(os.environ.get('DEF_EXTRACT_GA', False)) api_ver = os.environ.get('DEF_API_VER', "1") # MTCNN parameters select_largest = tobool(os.environ.get("SELECT_LARGEST", True)) keep_all = tobool(os.environ.get("KEEP_ALL", True)) min_face_size = int(os.environ.get("MIN_FACE_SIZE", 20)) mtcnn_factor = float(os.environ.get("MTCNN_FACTOR", 0.709)) processing = Processing(det_name=det_name, rec_name=rec_name, ga_name=ga_name, device=device, max_size=max_size,select_largest=select_largest, keep_all=keep_all, min_face_size=min_face_size,
backend_name = os.getenv('INFERENCE_BACKEND', 'trt') rec_name = os.getenv("REC_NAME", "arcface_r100_v1") det_name = os.getenv("DET_NAME", "retinaface_mnet025_v2") ga_name = os.getenv("GA_NAME", "genderage_v1") ga_ignore = tobool(os.getenv('GA_IGNORE', False)) rec_ignore = tobool(os.getenv('REC_IGNORE', False)) if rec_ignore: rec_name = None if ga_ignore: ga_name = None # Global parameters max_size = parse_size(os.getenv('MAX_SIZE')) return_face_data = tobool(os.getenv('DEF_RETURN_FACE_DATA', False)) extract_embedding = tobool(os.getenv('DEF_EXTRACT_EMBEDDING', True)) extract_ga = tobool(os.getenv('DEF_EXTRACT_GA', False)) api_ver = os.getenv('DEF_API_VER', "1") # MTCNN parameters select_largest = tobool(os.getenv("SELECT_LARGEST", True)) keep_all = tobool(os.getenv("KEEP_ALL", True)) min_face_size = int(os.getenv("MIN_FACE_SIZE", 20)) mtcnn_factor = float(os.getenv("MTCNN_FACTOR", 0.709)) logging.basicConfig( level=log_level, format='%(asctime)s %(levelname)s - %(message)s', datefmt='[%H:%M:%S]',