freealise commited on
Commit
ac2a5c7
1 Parent(s): 52145da

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -16,9 +16,11 @@ from depth_anything.dpt import DepthAnything
16
  from depth_anything.util.transform import Resize, NormalizeImage, PrepareForNet
17
  from moviepy.editor import *
18
 
19
- def zip_files(files):
20
  with ZipFile("depth_result.zip", "w") as zipObj:
21
- for idx, file in enumerate(files):
 
 
22
  zipObj.write(file, file.split("/")[-1])
23
  return "depth_result.zip"
24
 
@@ -106,11 +108,13 @@ def make_video(video_path, outdir='./vis_video_depth', encoder='vits'):
106
  #out = cv2.VideoWriter(output_path, fourcc, frame_rate, (output_width, frame_height))
107
  count=0
108
  depth_frames = []
 
109
  while raw_video.isOpened():
110
  ret, raw_frame = raw_video.read()
111
  if not ret:
112
  break
113
-
 
114
  frame = cv2.cvtColor(raw_frame, cv2.COLOR_BGR2RGB) / 255.0
115
  frame_pil = Image.fromarray((frame * 255).astype(np.uint8))
116
  frame = transform({'image': frame})['image']
@@ -148,7 +152,7 @@ def make_video(video_path, outdir='./vis_video_depth', encoder='vits'):
148
  count += 1
149
 
150
  final_vid = create_video(depth_frames, frame_rate, "depth")
151
- final_zip = zip_files(depth_frames)
152
  raw_video.release()
153
  # out.release()
154
  cv2.destroyAllWindows()
 
16
  from depth_anything.util.transform import Resize, NormalizeImage, PrepareForNet
17
  from moviepy.editor import *
18
 
19
+ def zip_files(files_in, files_out):
20
  with ZipFile("depth_result.zip", "w") as zipObj:
21
+ for idx, file in enumerate(files_in):
22
+ zipObj.write(file, file.split("/")[-1])
23
+ for idx, file in enumerate(files_out):
24
  zipObj.write(file, file.split("/")[-1])
25
  return "depth_result.zip"
26
 
 
108
  #out = cv2.VideoWriter(output_path, fourcc, frame_rate, (output_width, frame_height))
109
  count=0
110
  depth_frames = []
111
+ orig_frames = []
112
  while raw_video.isOpened():
113
  ret, raw_frame = raw_video.read()
114
  if not ret:
115
  break
116
+
117
+ orig_frames.append(raw_frame)
118
  frame = cv2.cvtColor(raw_frame, cv2.COLOR_BGR2RGB) / 255.0
119
  frame_pil = Image.fromarray((frame * 255).astype(np.uint8))
120
  frame = transform({'image': frame})['image']
 
152
  count += 1
153
 
154
  final_vid = create_video(depth_frames, frame_rate, "depth")
155
+ final_zip = zip_files(orig_frames, depth_frames)
156
  raw_video.release()
157
  # out.release()
158
  cv2.destroyAllWindows()