use mjpeg and convert bgr to rgb

This commit is contained in:
underlines
2024-08-30 21:49:01 +02:00
parent 3107f74165
commit 79c6615a68
3 changed files with 17 additions and 3 deletions

View File

@@ -1,6 +1,7 @@
import numpy
import opennsfw2
from PIL import Image
import cv2 # Add OpenCV import
from modules.typing import Frame
@@ -10,6 +11,8 @@ MAX_PROBABILITY = 0.85
model = None
def predict_frame(target_frame: Frame) -> bool:
# Convert the frame to RGB before processing
target_frame = cv2.cvtColor(target_frame, cv2.COLOR_BGR2RGB)
image = Image.fromarray(target_frame)
image = opennsfw2.preprocess_image(image, opennsfw2.Preprocessing.YAHOO)
global model