Yaroslav
commited on
by cro
Browse files
app.py
CHANGED
@@ -1,10 +1,6 @@
|
|
1 |
import cv2
|
2 |
import os
|
3 |
import gradio as gr
|
4 |
-
from super_slo import SuperSlo
|
5 |
-
|
6 |
-
# Инициализация модели SuperSlo для интерполяции
|
7 |
-
model = SuperSlo()
|
8 |
|
9 |
# Функция для увеличения FPS
|
10 |
def increase_fps(input_video_path, target_fps=60):
|
@@ -30,17 +26,25 @@ def increase_fps(input_video_path, target_fps=60):
|
|
30 |
output.release()
|
31 |
raise ValueError("Не удалось прочитать кадры из видео.")
|
32 |
|
|
|
|
|
33 |
while True:
|
34 |
ret, next_frame = cap.read()
|
35 |
if not ret:
|
36 |
break
|
37 |
|
|
|
|
|
|
|
|
|
38 |
for i in range(1, int(ratio)):
|
39 |
alpha = i / ratio
|
40 |
-
|
|
|
41 |
output.write(intermediate_frame)
|
42 |
|
43 |
output.write(next_frame)
|
|
|
44 |
prev_frame = next_frame
|
45 |
|
46 |
cap.release()
|
|
|
1 |
import cv2
|
2 |
import os
|
3 |
import gradio as gr
|
|
|
|
|
|
|
|
|
4 |
|
5 |
# Функция для увеличения FPS
|
6 |
def increase_fps(input_video_path, target_fps=60):
|
|
|
26 |
output.release()
|
27 |
raise ValueError("Не удалось прочитать кадры из видео.")
|
28 |
|
29 |
+
prev_frame_gray = cv2.cvtColor(prev_frame, cv2.COLOR_BGR2GRAY)
|
30 |
+
|
31 |
while True:
|
32 |
ret, next_frame = cap.read()
|
33 |
if not ret:
|
34 |
break
|
35 |
|
36 |
+
next_frame_gray = cv2.cvtColor(next_frame, cv2.COLOR_BGR2GRAY)
|
37 |
+
|
38 |
+
flow = cv2.calcOpticalFlowFarneback(prev_frame_gray, next_frame_gray, None, 0.5, 3, 15, 3, 5, 1.2, 0)
|
39 |
+
|
40 |
for i in range(1, int(ratio)):
|
41 |
alpha = i / ratio
|
42 |
+
flow_intermediate = flow * alpha
|
43 |
+
intermediate_frame = cv2.remap(prev_frame, flow_intermediate, None, cv2.INTER_LINEAR)
|
44 |
output.write(intermediate_frame)
|
45 |
|
46 |
output.write(next_frame)
|
47 |
+
prev_frame_gray = next_frame_gray
|
48 |
prev_frame = next_frame
|
49 |
|
50 |
cap.release()
|