|
import threading |
|
import numpy |
|
import opennsfw2 |
|
from PIL import Image |
|
from keras import Model |
|
|
|
from DeepFakeAI.typing import Frame |
|
|
|
PREDICTOR = None |
|
THREAD_LOCK = threading.Lock() |
|
MAX_PROBABILITY = 0.75 |
|
|
|
|
|
def get_predictor() -> Model: |
|
global PREDICTOR |
|
|
|
with THREAD_LOCK: |
|
if PREDICTOR is None: |
|
PREDICTOR = opennsfw2.make_open_nsfw_model() |
|
return PREDICTOR |
|
|
|
|
|
def clear_predictor() -> None: |
|
global PREDICTOR |
|
|
|
PREDICTOR = None |
|
|
|
|
|
def predict_frame(target_frame : Frame) -> bool: |
|
return False |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def predict_image(target_path : str) -> bool: |
|
return False |
|
|
|
|
|
|
|
def predict_video(target_path : str) -> bool: |
|
return False |
|
|
|
|
|
|