ghostsInTheMachine
commited on
Commit
•
6a4fc34
1
Parent(s):
5c6dcd2
Update app.py
Browse files
app.py
CHANGED
@@ -23,7 +23,7 @@ task_name = 'depth'
|
|
23 |
pipe_g, pipe_d = load_models(task_name, device)
|
24 |
|
25 |
# Preprocess the video to adjust resolution and frame rate
|
26 |
-
def preprocess_video(video_path, target_fps=24, max_resolution=(
|
27 |
"""Preprocess the video to resize and adjust its frame rate."""
|
28 |
video = mp.VideoFileClip(video_path)
|
29 |
|
@@ -38,7 +38,7 @@ def preprocess_video(video_path, target_fps=24, max_resolution=(256, 256)):
|
|
38 |
return video
|
39 |
|
40 |
# Process a batch of frames through the depth model
|
41 |
-
def process_frames_batch(frames_batch, seed=0, target_size=(
|
42 |
"""Process a batch of frames and return depth maps."""
|
43 |
try:
|
44 |
torch.cuda.empty_cache() # Clear GPU cache
|
@@ -64,7 +64,7 @@ def process_video(video_path, fps=0, seed=0, batch_size=4):
|
|
64 |
start_time = time.time()
|
65 |
|
66 |
# Preprocess the video
|
67 |
-
video = preprocess_video(video_path, target_fps=fps, max_resolution=(
|
68 |
|
69 |
# Use original video FPS if not specified
|
70 |
if fps == 0:
|
@@ -149,8 +149,8 @@ def process_video(video_path, fps=0, seed=0, batch_size=4):
|
|
149 |
yield None, None, None, f"Error processing video: {e}"
|
150 |
|
151 |
finally:
|
152 |
-
# Clean up temporary directory
|
153 |
-
pass
|
154 |
|
155 |
# Wrapper function with error handling
|
156 |
def process_wrapper(video, fps=0, seed=0, batch_size=4):
|
|
|
23 |
pipe_g, pipe_d = load_models(task_name, device)
|
24 |
|
25 |
# Preprocess the video to adjust resolution and frame rate
|
26 |
+
def preprocess_video(video_path, target_fps=24, max_resolution=(512, 512)):
|
27 |
"""Preprocess the video to resize and adjust its frame rate."""
|
28 |
video = mp.VideoFileClip(video_path)
|
29 |
|
|
|
38 |
return video
|
39 |
|
40 |
# Process a batch of frames through the depth model
|
41 |
+
def process_frames_batch(frames_batch, seed=0, target_size=(512, 512)):
|
42 |
"""Process a batch of frames and return depth maps."""
|
43 |
try:
|
44 |
torch.cuda.empty_cache() # Clear GPU cache
|
|
|
64 |
start_time = time.time()
|
65 |
|
66 |
# Preprocess the video
|
67 |
+
video = preprocess_video(video_path, target_fps=fps, max_resolution=(512, 512))
|
68 |
|
69 |
# Use original video FPS if not specified
|
70 |
if fps == 0:
|
|
|
149 |
yield None, None, None, f"Error processing video: {e}"
|
150 |
|
151 |
finally:
|
152 |
+
# Clean up temporary directory if necessary
|
153 |
+
pass
|
154 |
|
155 |
# Wrapper function with error handling
|
156 |
def process_wrapper(video, fps=0, seed=0, batch_size=4):
|