Yaroslav commited on
Commit
74d9fa2
·
verified ·
1 Parent(s): d253b3a
Files changed (1) hide show
  1. app.py +2 -11
app.py CHANGED
@@ -2,7 +2,6 @@ import cv2
2
  import os
3
  import gradio as gr
4
 
5
- # Функция для увеличения FPS
6
  def increase_fps(input_video_path, target_fps=60):
7
  output_path = "output.mp4"
8
  cap = cv2.VideoCapture(input_video_path)
@@ -26,25 +25,17 @@ 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()
@@ -60,7 +51,7 @@ interface = gr.Interface(
60
  inputs=gr.Video(label="Загрузите видео для обработки"),
61
  outputs=gr.Video(label="Видео с увеличенным FPS"),
62
  title="Увеличение FPS до 60",
63
- description="Этот инструмент увеличивает частоту кадров видео до 60 FPS с использованием оптического потока. Загрузите видео с низким FPS, чтобы получить плавный результат.",
64
  examples=[]
65
  )
66
 
 
2
  import os
3
  import gradio as gr
4
 
 
5
  def increase_fps(input_video_path, target_fps=60):
6
  output_path = "output.mp4"
7
  cap = cv2.VideoCapture(input_video_path)
 
25
  output.release()
26
  raise ValueError("Не удалось прочитать кадры из видео.")
27
 
 
 
28
  while True:
29
  ret, next_frame = cap.read()
30
  if not ret:
31
  break
32
 
 
 
 
 
33
  for i in range(1, int(ratio)):
34
  alpha = i / ratio
35
+ intermediate_frame = cv2.addWeighted(prev_frame, 1 - alpha, next_frame, alpha, 0)
 
36
  output.write(intermediate_frame)
37
 
38
  output.write(next_frame)
 
39
  prev_frame = next_frame
40
 
41
  cap.release()
 
51
  inputs=gr.Video(label="Загрузите видео для обработки"),
52
  outputs=gr.Video(label="Видео с увеличенным FPS"),
53
  title="Увеличение FPS до 60",
54
+ description="Этот инструмент увеличивает частоту кадров видео до 60 FPS с использованием интерполяции. Загрузите видео с низким FPS, чтобы получить плавный результат.",
55
  examples=[]
56
  )
57