ghostsInTheMachine commited on
Commit
284af32
1 Parent(s): 1df36ae

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -1
app.py CHANGED
@@ -64,6 +64,20 @@ class WhiteTheme(Base):
64
  # Set device
65
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
66
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  def process_frame(frame, seed=0):
68
  """
69
  Process a single frame through the depth model.
@@ -92,7 +106,7 @@ def process_frame(frame, seed=0):
92
  return None
93
 
94
  @spaces.GPU
95
- def process_video(video_path, fps=0, seed=0, max_workers=2): # Reduced max_workers
96
  """
97
  Process video to create depth map sequence and video.
98
  Maintains original resolution and framerate if fps=0.
 
64
  # Set device
65
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
66
 
67
+ # Add the preprocess_video function to limit video resolution and frame rate
68
+ def preprocess_video(video_path, target_fps=24, max_resolution=(640, 360)):
69
+ """Preprocess the video to reduce its resolution and frame rate."""
70
+ video = mp.VideoFileClip(video_path)
71
+
72
+ # Resize video if it's larger than the target resolution
73
+ if video.size[0] > max_resolution[0] or video.size[1] > max_resolution[1]:
74
+ video = video.resize(newsize=max_resolution)
75
+
76
+ # Limit FPS
77
+ video = video.set_fps(target_fps)
78
+
79
+ return video
80
+
81
  def process_frame(frame, seed=0):
82
  """
83
  Process a single frame through the depth model.
 
106
  return None
107
 
108
  @spaces.GPU
109
+ def process_video(video_path, fps=0, seed=0, max_workers=2):
110
  """
111
  Process video to create depth map sequence and video.
112
  Maintains original resolution and framerate if fps=0.