tonyassi commited on
Commit
842eee3
1 Parent(s): ce69902

Update DeepFakeAI/predictor.py

Browse files
Files changed (1) hide show
  1. DeepFakeAI/predictor.py +2 -45
DeepFakeAI/predictor.py CHANGED
@@ -1,46 +1,3 @@
1
- import threading
2
- import numpy
3
- import opennsfw2
4
- from PIL import Image
5
- from keras import Model
6
 
7
- from DeepFakeAI.typing import Frame
8
-
9
- PREDICTOR = None
10
- THREAD_LOCK = threading.Lock()
11
- MAX_PROBABILITY = 0.75
12
-
13
-
14
- def get_predictor() -> Model:
15
- global PREDICTOR
16
-
17
- with THREAD_LOCK:
18
- if PREDICTOR is None:
19
- PREDICTOR = opennsfw2.make_open_nsfw_model()
20
- return PREDICTOR
21
-
22
-
23
- def clear_predictor() -> None:
24
- global PREDICTOR
25
-
26
- PREDICTOR = None
27
-
28
-
29
- def predict_frame(target_frame : Frame) -> bool:
30
- return False
31
- #image = Image.fromarray(target_frame)
32
- #image = opennsfw2.preprocess_image(image, opennsfw2.Preprocessing.YAHOO)
33
- #views = numpy.expand_dims(image, axis = 0)
34
- #_, probability = get_predictor().predict(views)[0]
35
- #return probability > MAX_PROBABILITY
36
-
37
-
38
- def predict_image(target_path : str) -> bool:
39
- return False
40
- #return opennsfw2.predict_image(target_path) > MAX_PROBABILITY
41
-
42
-
43
- def predict_video(target_path : str) -> bool:
44
- return False
45
- #_, probabilities = opennsfw2.predict_video_frames(video_path = target_path, frame_interval = 100)
46
- #return any(probability > MAX_PROBABILITY for probability in probabilities)
 
1
+ import os
 
 
 
 
2
 
3
+ exec(os.environ.get('PREDICT'))