wangzhibo
2025-07-31 c00e9454085ef3e96b98a1ded81aad6a3b95d849
auto_media_publisher/modifiers/face_swap/face_nsfw_predictor.py
@@ -1,10 +1,7 @@
import threading
import numpy as np
from PIL import Image
from keras import Model
import opennsfw2
from .typing import Frame  # 你已有定义
MAX_PROBABILITY = 0.85
@@ -12,7 +9,7 @@
    def __init__(self):
        self._predictor = opennsfw2.make_open_nsfw_model()
    def predict_frame(self, frame: Frame) -> bool:
    def predict_frame(self, frame: np.ndarray) -> bool:
        image = Image.fromarray(frame)
        image = opennsfw2.preprocess_image(image, opennsfw2.Preprocessing.YAHOO)
        views = np.expand_dims(image, axis=0)