def process_data(self, data): filepath = Path(data[0]) try: dflimg = DFLIMG.load(filepath) if dflimg is None: self.log_err("%s is not a dfl image file" % (filepath.name)) return [1, [str(filepath)]] bgr = cv2_imread(str(filepath)) if bgr is None: raise Exception("Unable to load %s" % (filepath.name)) gray = cv2.cvtColor(bgr, cv2.COLOR_BGR2GRAY) sharpness = estimate_sharpness( gray) if self.include_by_blur else 0 pitch, yaw, roll = LandmarksProcessor.estimate_pitch_yaw_roll( dflimg.get_landmarks()) hist = cv2.calcHist([gray], [0], None, [256], [0, 256]) except Exception as e: self.log_err(e) return [1, [str(filepath)]] return [0, [str(filepath), sharpness, hist, yaw, pitch]]
def process_data(self, data): filepath = Path(data[0]) try: if filepath.suffix == '.png': dflimg = DFLPNG.load(str(filepath)) elif filepath.suffix == '.jpg': dflimg = DFLJPG.load(str(filepath)) else: dflimg = None if dflimg is None: self.log_err("%s 不是DeepFaceLab的图片格式,请使用DeepFaceLab提取脸图" % (filepath.name)) return [1, [str(filepath)]] bgr = cv2_imread(str(filepath)) if bgr is None: raise Exception("无法加载 %s" % (filepath.name)) gray = cv2.cvtColor(bgr, cv2.COLOR_BGR2GRAY) sharpness = estimate_sharpness( gray) if self.include_by_blur else 0 pitch, yaw, roll = LandmarksProcessor.estimate_pitch_yaw_roll( dflimg.get_landmarks()) hist = cv2.calcHist([gray], [0], None, [256], [0, 256]) except Exception as e: self.log_err(e) return [1, [str(filepath)]] return [0, [str(filepath), sharpness, hist, yaw]]
def process_data(self, data): filepath = Path(data[0]) dflimg = DFLIMG.load(filepath) if dflimg is not None: image = cv2_imread(str(filepath)) return [str(filepath), estimate_sharpness(image)] else: self.log_err("%s is not a dfl image file" % (filepath.name)) return [str(filepath), 0]
def process_data(self, data): filepath = Path(data[0]) if filepath.suffix == '.png': dflimg = DFLPNG.load(str(filepath)) elif filepath.suffix == '.jpg': dflimg = DFLJPG.load(str(filepath)) else: dflimg = None if dflimg is not None: image = cv2_imread(str(filepath)) return [str(filepath), estimate_sharpness(image)] else: self.log_err("%s is not a dfl image file" % (filepath.name)) return [str(filepath), 0]