def convert_images(self): """ Convert the images """ logger.debug("Converting images") save_queue = queue_manager.get_queue("convert_out") patch_queue = queue_manager.get_queue("patch") completion_queue = queue_manager.get_queue("patch_completed") pool = PoolProcess(self.converter.process, patch_queue, save_queue, completion_queue=completion_queue, processes=self.pool_processes) pool.start() completed_count = 0 while True: self.check_thread_error() if self.disk_io.completion_event.is_set(): logger.debug("DiskIO completion event set. Joining Pool") break try: completed = completion_queue.get(True, 1) except QueueEmpty: continue completed_count += completed logger.debug("Total process pools completed: %s of %s", completed_count, pool.procs) if completed_count == pool.procs: logger.debug("All processes completed. Joining Pool") break pool.join() logger.debug("Putting EOF") save_queue.put("EOF") logger.debug("Converted images")
def launch_detector(self): """ Launch the face detector """ out_queue = queue_manager.get_queue("detect") kwargs = {"in_queue": queue_manager.get_queue("load"), "out_queue": out_queue} if self.args.detector == "mtcnn": mtcnn_kwargs = self.detector.validate_kwargs( self.get_mtcnn_kwargs()) kwargs["mtcnn_kwargs"] = mtcnn_kwargs if self.detector.parent_is_pool: self.process_detect = PoolProcess(self.detector.detect_faces) else: self.process_detect = SpawnProcess() event = None if hasattr(self.process_detect, "event"): event = self.process_detect.event self.process_detect.in_process(self.detector.detect_faces, **kwargs) if not event: return event.wait(60) if not event.is_set(): raise ValueError("Error inititalizing Detector")
def convert_images(self): """ Convert the images """ logger.debug("Converting images") save_queue = queue_manager.get_queue("save") patch_queue = queue_manager.get_queue("patch") pool = PoolProcess(self.converter.process, patch_queue, save_queue, processes=self.pool_processes) pool.start() while True: self.check_thread_error() if self.disk_io.completion_event.is_set(): break sleep(1) pool.join() save_queue.put("EOF") logger.debug("Converted images")