Update app.py
Browse files
app.py
CHANGED
@@ -30,12 +30,15 @@ def process_video(video_path, frame_difference, brightness_value):
|
|
30 |
|
31 |
cap.release()
|
32 |
|
|
|
|
|
|
|
|
|
33 |
# Process video by applying frame difference and overlaying
|
34 |
-
num_frames = len(frames)
|
35 |
for i in range(num_frames):
|
36 |
# Get the original and shifted frames
|
37 |
orig_frame = frames[i][0]
|
38 |
-
shifted_index = (i + frame_difference) %
|
39 |
shifted_frame = frames[shifted_index][1] # Use the inverted frame of shifted frame
|
40 |
|
41 |
# Overlay the frames with 50% opacity
|
@@ -56,8 +59,8 @@ iface = gr.Interface(
|
|
56 |
fn=process_video,
|
57 |
inputs=[
|
58 |
gr.Video(label="Input Video"), # Video input
|
59 |
-
gr.Slider(0, 50, value=1, label="Frame Difference"), # Frame difference input
|
60 |
-
gr.Slider(0.0,
|
61 |
],
|
62 |
outputs=gr.Video(label="Output Video"), # Video output
|
63 |
title="Motion Amplification with Frame Difference"
|
|
|
30 |
|
31 |
cap.release()
|
32 |
|
33 |
+
# Calculate number of frames to process (Original length minus frame difference)
|
34 |
+
num_frames = len(frames) - frame_difference
|
35 |
+
num_frames = max(num_frames, 0) # Ensure non-negative
|
36 |
+
|
37 |
# Process video by applying frame difference and overlaying
|
|
|
38 |
for i in range(num_frames):
|
39 |
# Get the original and shifted frames
|
40 |
orig_frame = frames[i][0]
|
41 |
+
shifted_index = (i + frame_difference) % len(frames)
|
42 |
shifted_frame = frames[shifted_index][1] # Use the inverted frame of shifted frame
|
43 |
|
44 |
# Overlay the frames with 50% opacity
|
|
|
59 |
fn=process_video,
|
60 |
inputs=[
|
61 |
gr.Video(label="Input Video"), # Video input
|
62 |
+
gr.Slider(0, 50, step=1, value=1, label="Frame Difference (Integer)"), # Integer Frame difference input
|
63 |
+
gr.Slider(0.0, 2.0, value=1.0, step=0.1, label="Brightness Adjustment (0.0 to 2.0)"), # Brightness adjustment input
|
64 |
],
|
65 |
outputs=gr.Video(label="Output Video"), # Video output
|
66 |
title="Motion Amplification with Frame Difference"
|