Spaces:
Build error
Build error
Commit
·
96e5a5e
1
Parent(s):
13b5277
Update app.py
Browse files
app.py
CHANGED
@@ -1,18 +1,16 @@
|
|
1 |
import tensorflow.keras as K
|
2 |
from tensorflow.keras import layers
|
3 |
-
|
4 |
import keras
|
5 |
-
|
6 |
import os
|
7 |
import tensorflow as tf
|
8 |
import gradio as gr
|
9 |
from extract_landmarks import get_data_for_test,extract_landmark,merge_video_prediction
|
|
|
10 |
|
11 |
block_size = 60
|
12 |
DROPOUT_RATE = 0.5
|
13 |
RNN_UNIT = 64
|
14 |
os.environ["KMP_DUPLICATE_LIB_OK"]="TRUE"
|
15 |
-
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
|
16 |
os.environ["CUDA_VISIBLE_DEVICES"] = "0"
|
17 |
|
18 |
gpus = tf.config.list_physical_devices(device_type='GPU')
|
@@ -21,6 +19,8 @@ for gpu in gpus:
|
|
21 |
device = "CPU" if len(gpus) == 0 else "GPU"
|
22 |
print("using {}".format(device))
|
23 |
|
|
|
|
|
24 |
def predict(video):
|
25 |
path = extract_landmark(video)
|
26 |
test_samples, test_samples_diff, _, _, test_sv, test_vc = get_data_for_test(path, 1, block_size)
|
@@ -79,10 +79,12 @@ def predict(video):
|
|
79 |
else:
|
80 |
label = "Real"
|
81 |
print("the pd is {}".format(pd))
|
82 |
-
|
|
|
|
|
83 |
|
84 |
inputs = gr.inputs.Video()
|
85 |
-
outputs = gr.outputs.Textbox()
|
86 |
iface = gr.Interface(fn=predict, inputs=inputs, outputs=outputs,
|
87 |
examples=[["sample__real.mp4"],["sample__fake.mp4"],["sample__real2.mp4"],["sample__fake2.mp4"]],
|
88 |
theme = "grass",
|
|
|
1 |
import tensorflow.keras as K
|
2 |
from tensorflow.keras import layers
|
|
|
3 |
import keras
|
|
|
4 |
import os
|
5 |
import tensorflow as tf
|
6 |
import gradio as gr
|
7 |
from extract_landmarks import get_data_for_test,extract_landmark,merge_video_prediction
|
8 |
+
from detect_from_videos import test_full_image_network
|
9 |
|
10 |
block_size = 60
|
11 |
DROPOUT_RATE = 0.5
|
12 |
RNN_UNIT = 64
|
13 |
os.environ["KMP_DUPLICATE_LIB_OK"]="TRUE"
|
|
|
14 |
os.environ["CUDA_VISIBLE_DEVICES"] = "0"
|
15 |
|
16 |
gpus = tf.config.list_physical_devices(device_type='GPU')
|
|
|
19 |
device = "CPU" if len(gpus) == 0 else "GPU"
|
20 |
print("using {}".format(device))
|
21 |
|
22 |
+
model_path = '3_ff_raw.pkl'
|
23 |
+
|
24 |
def predict(video):
|
25 |
path = extract_landmark(video)
|
26 |
test_samples, test_samples_diff, _, _, test_sv, test_vc = get_data_for_test(path, 1, block_size)
|
|
|
79 |
else:
|
80 |
label = "Real"
|
81 |
print("the pd is {}".format(pd))
|
82 |
+
|
83 |
+
output_video = test_full_image_network(video,model_path)
|
84 |
+
return label,output_video
|
85 |
|
86 |
inputs = gr.inputs.Video()
|
87 |
+
outputs = [gr.outputs.Textbox(),gr.Video()]
|
88 |
iface = gr.Interface(fn=predict, inputs=inputs, outputs=outputs,
|
89 |
examples=[["sample__real.mp4"],["sample__fake.mp4"],["sample__real2.mp4"],["sample__fake2.mp4"]],
|
90 |
theme = "grass",
|