def launch_aligner(self): """ Load the aligner plugin to retrieve landmarks """ out_queue = queue_manager.get_queue("out") kwargs = {"in_queue": queue_manager.get_queue("in"), "out_queue": out_queue} for plugin in ("fan", "cv2_dnn"): aligner = PluginLoader.get_aligner(plugin)(loglevel=self.args.loglevel) process = SpawnProcess(aligner.run, **kwargs) event = process.event process.start() # Wait for Aligner to take init # The first ever load of the model for FAN has reportedly taken # up to 3-4 minutes, hence high timeout. event.wait(300) if not event.is_set(): if plugin == "fan": process.join() logger.error("Error initializing FAN. Trying CV2-DNN") continue else: raise ValueError("Error inititalizing Aligner") if plugin == "cv2_dnn": return try: err = None err = out_queue.get(True, 1) except QueueEmpty: pass if not err: break process.join() logger.error("Error initializing FAN. Trying CV2-DNN")
def launch_aligner(): """ Load the aligner plugin to retrieve landmarks """ out_queue = queue_manager.get_queue("out") kwargs = {"in_queue": queue_manager.get_queue("in"), "out_queue": out_queue} process = SpawnProcess() event = process.event for plugin in ("fan", "dlib"): aligner = PluginLoader.get_aligner(plugin)() process.in_process(aligner.align, **kwargs) # Wait for Aligner to take init # The first ever load of the model for FAN has reportedly taken # up to 3-4 minutes, hence high timeout. event.wait(300) if not event.is_set(): if plugin == "fan": process.join() print("Error initializing FAN. Trying Dlib") continue else: raise ValueError("Error inititalizing Aligner") if plugin == "dlib": return try: err = None err = out_queue.get(True, 1) except QueueEmpty: pass if not err: break process.join() print("Error initializing FAN. Trying Dlib")
def load_aligner(aligner, loglevel, configfile): """ Set global arguments and load aligner plugin """ aligner_name = aligner.replace("-", "_").lower() logger.debug("Loading Aligner: '%s'", aligner_name) aligner = PluginLoader.get_aligner(aligner_name)(loglevel=loglevel, configfile=configfile) return aligner
def load_extractor(self): """ Set on the fly extraction """ logger.warning("No Alignments file found. Extracting on the fly.") logger.warning("NB: This will use the inferior dlib-hog for extraction " "and dlib pose predictor for landmarks. It is recommended " "to perfom Extract first for superior results") for task in ("load", "detect", "align"): queue_manager.add_queue(task, maxsize=0) detector = PluginLoader.get_detector("dlib_hog")(loglevel=self.args.loglevel) aligner = PluginLoader.get_aligner("dlib")(loglevel=self.args.loglevel) d_kwargs = {"in_queue": queue_manager.get_queue("load"), "out_queue": queue_manager.get_queue("detect")} a_kwargs = {"in_queue": queue_manager.get_queue("detect"), "out_queue": queue_manager.get_queue("align")} d_process = SpawnProcess(detector.run, **d_kwargs) d_event = d_process.event d_process.start() a_process = SpawnProcess(aligner.run, **a_kwargs) a_event = a_process.event a_process.start() d_event.wait(10) if not d_event.is_set(): raise ValueError("Error inititalizing Detector") a_event.wait(10) if not a_event.is_set(): raise ValueError("Error inititalizing Aligner") self.extract_faces = True
def _load_aligner(aligner, configfile, normalize_method): """ Set global arguments and load aligner plugin """ aligner_name = aligner.replace("-", "_").lower() logger.debug("Loading Aligner: '%s'", aligner_name) aligner = PluginLoader.get_aligner(aligner_name)( configfile=configfile, normalize_method=normalize_method) return aligner
def init_extractor(self, loglevel, amd): """ Initialize Aligner """ logger.debug("Initialize Extractor") out_queue = queue_manager.get_queue("out") d_kwargs = { "in_queue": queue_manager.get_queue("in"), "out_queue": queue_manager.get_queue("align") } a_kwargs = { "in_queue": queue_manager.get_queue("align"), "out_queue": out_queue } detector = PluginLoader.get_detector("manual")(loglevel=loglevel) detect_process = SpawnProcess(detector.run, **d_kwargs) d_event = detect_process.event detect_process.start() plugins = ["fan_amd"] if amd else ["fan"] plugins.append("cv2_dnn") for plugin in plugins: aligner = PluginLoader.get_aligner(plugin)(loglevel=loglevel, normalize_method="hist") align_process = SpawnProcess(aligner.run, **a_kwargs) a_event = align_process.event align_process.start() # Wait for Aligner to initialize # The first ever load of the model for FAN has reportedly taken # up to 3-4 minutes, hence high timeout. a_event.wait(300) if not a_event.is_set(): if plugin.startswith("fan"): align_process.join() logger.error("Error initializing FAN. Trying CV2-DNN") continue else: raise ValueError("Error inititalizing Aligner") if plugin == "cv2_dnn": break try: err = None err = out_queue.get(True, 1) except QueueEmpty: pass if not err: break align_process.join() logger.error("Error initializing FAN. Trying CV2-DNN") d_event.wait(10) if not d_event.is_set(): raise ValueError("Error inititalizing Detector") self.extractor["detect"] = detector self.extractor["align"] = aligner logger.debug("Initialized Extractor")
def load_aligner(self): """ Set global arguments and load aligner plugin """ aligner_name = self.args.aligner.replace("-", "_").lower() aligner = PluginLoader.get_aligner(aligner_name)( verbose=self.args.verbose) return aligner
def load_aligner(self): """ Set global arguments and load aligner plugin """ aligner_name = self.args.aligner.replace("-", "_").lower() logger.debug("Loading Aligner: '%s'", aligner_name) aligner = PluginLoader.get_aligner(aligner_name)( loglevel=self.args.loglevel) return aligner
def launch_aligner(): """ Load the aligner plugin to retrieve landmarks """ kwargs = dict(in_queue=queue_manager.get_queue("in"), out_queue=queue_manager.get_queue("out"), queue_size=8) aligner = PluginLoader.get_aligner("fan")(normalize_method="hist") aligner.batchsize = 1 aligner.initialize(**kwargs) aligner.start()
def _load_align(aligner, configfile, normalize_method): """ Set global arguments and load aligner plugin """ if aligner is None or aligner.lower() == "none": logger.debug("No aligner selected. Returning None") return None aligner_name = aligner.replace("-", "_").lower() logger.debug("Loading Aligner: '%s'", aligner_name) aligner = PluginLoader.get_aligner(aligner_name)( configfile=configfile, normalize_method=normalize_method) return aligner
def init_extractor(self, loglevel): """ Initialize FAN """ out_queue = queue_manager.get_queue("out") d_kwargs = { "in_queue": queue_manager.get_queue("in"), "out_queue": queue_manager.get_queue("align") } a_kwargs = { "in_queue": queue_manager.get_queue("align"), "out_queue": out_queue } detector = PluginLoader.get_detector("manual")(loglevel=loglevel) detect_process = SpawnProcess(detector.run, **d_kwargs) d_event = detect_process.event detect_process.start() for plugin in ("fan", "dlib"): aligner = PluginLoader.get_aligner(plugin)(loglevel=loglevel) align_process = SpawnProcess(aligner.run, **a_kwargs) a_event = align_process.event align_process.start() # Wait for Aligner to take init # The first ever load of the model for FAN has reportedly taken # up to 3-4 minutes, hence high timeout. a_event.wait(300) if not a_event.is_set(): if plugin == "fan": align_process.join() logger.error("Error initializing FAN. Trying Dlib") continue else: raise ValueError("Error inititalizing Aligner") if plugin == "dlib": break try: err = None err = out_queue.get(True, 1) except QueueEmpty: pass if not err: break align_process.join() logger.error("Error initializing FAN. Trying Dlib") d_event.wait(10) if not d_event.is_set(): raise ValueError("Error inititalizing Detector") self.extractor["detect"] = detector self.extractor["align"] = aligner
def init_extractor(self, loglevel): """ Initialize FAN """ logger.debug("Initialize Extractor") out_queue = queue_manager.get_queue("out") d_kwargs = {"in_queue": queue_manager.get_queue("in"), "out_queue": queue_manager.get_queue("align")} a_kwargs = {"in_queue": queue_manager.get_queue("align"), "out_queue": out_queue} detector = PluginLoader.get_detector("manual")(loglevel=loglevel) detect_process = SpawnProcess(detector.run, **d_kwargs) d_event = detect_process.event detect_process.start() for plugin in ("fan", "cv2_dnn"): aligner = PluginLoader.get_aligner(plugin)(loglevel=loglevel) align_process = SpawnProcess(aligner.run, **a_kwargs) a_event = align_process.event align_process.start() # Wait for Aligner to initialize # The first ever load of the model for FAN has reportedly taken # up to 3-4 minutes, hence high timeout. a_event.wait(300) if not a_event.is_set(): if plugin == "fan": align_process.join() logger.error("Error initializing FAN. Trying CV2-DNN") continue else: raise ValueError("Error inititalizing Aligner") if plugin == "cv2_dnn": break try: err = None err = out_queue.get(True, 1) except QueueEmpty: pass if not err: break align_process.join() logger.error("Error initializing FAN. Trying CV2-DNN") d_event.wait(10) if not d_event.is_set(): raise ValueError("Error inititalizing Detector") self.extractor["detect"] = detector self.extractor["align"] = aligner logger.debug("Initialized Extractor")
def _load_align(self, aligner, configfile, normalize_method, re_feed): """ Set global arguments and load aligner plugin """ if aligner is None or aligner.lower() == "none": logger.debug("No aligner selected. Returning None") return None aligner_name = aligner.replace("-", "_").lower() logger.debug("Loading Aligner: '%s'", aligner_name) aligner = PluginLoader.get_aligner(aligner_name)(exclude_gpus=self._exclude_gpus, configfile=configfile, normalize_method=normalize_method, re_feed=re_feed, instance=self._instance) return aligner
def load_aligner(self): """ Set global arguments and load aligner plugin """ aligner_name = self.args.aligner.replace("-", "_").lower() # Align Eyes align_eyes = False if hasattr(self.args, 'align_eyes'): align_eyes = self.args.align_eyes # Extracted Face Size size = 256 if hasattr(self.args, 'size'): size = self.args.size aligner = PluginLoader.get_aligner(aligner_name)( verbose=self.args.verbose, align_eyes=align_eyes, size=size) return aligner
self.args.final_process = _final.replace('-', '_') self.sort_process() def launch_aligner(self): """ Load the aligner plugin to retrieve landmarks """ out_queue = queue_manager.get_queue("out") kwargs = {"in_queue": queue_manager.get_queue("in"), "out_queue": out_queue} <<<<<<< HEAD for plugin in ("fan", "dlib"): ======= for plugin in ("fan", "cv2_dnn"): >>>>>>> upstream/master aligner = PluginLoader.get_aligner(plugin)(loglevel=self.args.loglevel) process = SpawnProcess(aligner.run, **kwargs) event = process.event process.start() # Wait for Aligner to take init # The first ever load of the model for FAN has reportedly taken # up to 3-4 minutes, hence high timeout. event.wait(300) if not event.is_set(): if plugin == "fan": process.join() logger.error("Error initializing FAN. Trying CV2-DNN") continue else: raise ValueError("Error inititalizing Aligner")
def load_aligner(aligner, loglevel): """ Set global arguments and load aligner plugin """ aligner_name = aligner.replace("-", "_").lower() logger.debug("Loading Aligner: '%s'", aligner_name) aligner = PluginLoader.get_aligner(aligner_name)(loglevel=loglevel) return aligner