          if self.batch_size < 1:
              raise ValueError("Insufficient VRAM available to continue "
                               "({}MB)".format(int(vram_free)))
  
          logger.verbose("Processing in batches of %s", self.batch_size)
  
          self.init.set()
          logger.info("Initialized Dlib-CNN Detector...")
  
      def detect_faces(self, *args, **kwargs):
 
</s> remove         self.init.set()
        logger.info("Initialized Dlib-CNN Detector...")
 </s> add             self.init.set()
            logger.info("Initialized Dlib-CNN Detector...")
        except Exception as err:
            self.error.set()
            raise err </s> remove         if self.batch_size < 1:
            raise ValueError("Insufficient VRAM available to continue "
                             "({}MB)".format(int(vram_free)))
 </s> add             if self.batch_size < 1:
                raise ValueError("Insufficient VRAM available to continue "
                                 "({}MB)".format(int(vram_free))) </s> remove         super().initialize(*args, **kwargs)
        logger.info("Initializing S3FD Detector...")
        card_id, vram_free, vram_total = self.get_vram_free()
        if vram_free <= self.vram:
            tf_ratio = 1.0
        else:
            tf_ratio = self.vram / vram_total
        logger.verbose("Reserving %s%% of total VRAM per s3fd thread", round(tf_ratio, 2))

        confidence = self.config["confidence"] / 100
        self.model = S3fd(self.model_path, self.target, tf_ratio, card_id, confidence)

        if not self.model.is_gpu:
            alloc = 2048
            logger.warning("Using CPU")
        else:
            logger.debug("Using GPU")
            alloc = vram_free
        logger.debug("Allocated for Tensorflow: %sMB", alloc)

        self.batch_size = int(alloc / self.vram)

        if self.batch_size < 1:
            raise ValueError("Insufficient VRAM available to continue "
                             "({}MB)".format(int(alloc)))

        logger.verbose("Processing in %s threads", self.batch_size)

        self.init.set()
        logger.info("Initialized S3FD Detector.")
 </s> add         try:
            super().initialize(*args, **kwargs)
            logger.info("Initializing S3FD Detector...")
            card_id, vram_free, vram_total = self.get_vram_free()
            if vram_free <= self.vram:
                tf_ratio = 1.0
            else:
                tf_ratio = self.vram / vram_total
            logger.verbose("Reserving %s%% of total VRAM per s3fd thread",
                           round(tf_ratio * 100, 2))

            confidence = self.config["confidence"] / 100
            self.model = S3fd(self.model_path, self.target, tf_ratio, card_id, confidence)

            if not self.model.is_gpu:
                alloc = 2048
                logger.warning("Using CPU")
            else:
                logger.debug("Using GPU")
                alloc = vram_free
            logger.debug("Allocated for Tensorflow: %sMB", alloc)

            self.batch_size = int(alloc / self.vram)

            if self.batch_size < 1:
                raise ValueError("Insufficient VRAM available to continue "
                                 "({}MB)".format(int(alloc)))

            logger.verbose("Processing in %s threads", self.batch_size)

            self.init.set()
            logger.info("Initialized S3FD Detector.")
        except Exception as err:
            self.error.set()
            raise err </s> remove         self.kwargs["pnet"] = pnet
        self.kwargs["rnet"] = rnet
        self.kwargs["onet"] = onet
 </s> add             self.kwargs["pnet"] = pnet
            self.kwargs["rnet"] = rnet
            self.kwargs["onet"] = onet </s> remove         logger.verbose("Processing in %s threads", self.batch_size)
 </s> add             logger.verbose("Processing in %s threads", self.batch_size)
            logger.verbose("Processing in batches of %s", self.batch_size)
          if self.batch_size < 1:
              raise ValueError("Insufficient VRAM available to continue "
                               "({}MB)".format(int(vram_free)))
  
            logger.verbose("Processing in batches of %s", self.batch_size)
  
          self.init.set()
          logger.info("Initialized Dlib-CNN Detector...")
  
      def detect_faces(self, *args, **kwargs):
keep keep keep keep replace keep keep keep keep keep
 Better extractor error handling on initialization 
plugins/extract/detect/dlib_cnn.py