Spaces:
Runtime error
Runtime error
Delete roop/predicter.py
Browse files- roop/predicter.py +0 -25
roop/predicter.py
DELETED
@@ -1,25 +0,0 @@
|
|
1 |
-
import numpy
|
2 |
-
import opennsfw2
|
3 |
-
from PIL import Image
|
4 |
-
|
5 |
-
from roop.typing import Frame
|
6 |
-
|
7 |
-
MAX_PROBABILITY = 0.85
|
8 |
-
|
9 |
-
|
10 |
-
def predict_frame(target_frame: Frame) -> bool:
|
11 |
-
image = Image.fromarray(target_frame)
|
12 |
-
image = opennsfw2.preprocess_image(image, opennsfw2.Preprocessing.YAHOO)
|
13 |
-
model = opennsfw2.make_open_nsfw_model()
|
14 |
-
views = numpy.expand_dims(image, axis=0)
|
15 |
-
_, probability = model.predict(views)[0]
|
16 |
-
return probability > MAX_PROBABILITY
|
17 |
-
|
18 |
-
|
19 |
-
def predict_image(target_path: str) -> bool:
|
20 |
-
return opennsfw2.predict_image(target_path) > MAX_PROBABILITY
|
21 |
-
|
22 |
-
|
23 |
-
def predict_video(target_path: str) -> bool:
|
24 |
-
_, probabilities = opennsfw2.predict_video_frames(video_path=target_path, frame_interval=100)
|
25 |
-
return any(probability > MAX_PROBABILITY for probability in probabilities)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|