oxkitsune commited on
Commit
cb5d809
·
1 Parent(s): e8629d6

clean up video files

Browse files
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -13,7 +13,7 @@ from gradio_rerun import Rerun
13
  import spaces
14
 
15
  # Run the script to get pretrained models
16
- if not os.path.exists("checkpoints/depth_pro.pt"):
17
  print("downloading pretrained model")
18
  subprocess.run(["bash", "get_pretrained_models.sh"])
19
 
@@ -64,10 +64,11 @@ def run_rerun(path_to_video):
64
  break
65
 
66
  frame_idx += 1
67
- if frame_idx % 10 != 0:
68
  continue
69
 
70
- frame = cv2.resize(frame, (320, 240))
 
71
  frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
72
 
73
  rr.set_time_sequence("frame", frame_idx)
@@ -91,13 +92,15 @@ def run_rerun(path_to_video):
91
 
92
  rr.log(
93
  "world/camera/depth",
94
- # need 0.19 stable for this
95
- # rr.DepthImage(depth, meter=1, depth_range=(depth.min(), depth.max())),
96
  rr.DepthImage(depth, meter=1),
97
  )
98
 
99
  yield stream.read()
100
 
 
 
 
 
101
 
102
  @spaces.GPU(duration=40)
103
  def estimate_depth(frame):
 
13
  import spaces
14
 
15
  # Run the script to get pretrained models
16
+ if not os.path.exists("./checkpoints/depth_pro.pt"):
17
  print("downloading pretrained model")
18
  subprocess.run(["bash", "get_pretrained_models.sh"])
19
 
 
64
  break
65
 
66
  frame_idx += 1
67
+ if frame_idx % 3 != 0:
68
  continue
69
 
70
+ # resize to avoid excessive time spent processing
71
+ frame = cv2.resize(frame, (640, 480))
72
  frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
73
 
74
  rr.set_time_sequence("frame", frame_idx)
 
92
 
93
  rr.log(
94
  "world/camera/depth",
 
 
95
  rr.DepthImage(depth, meter=1),
96
  )
97
 
98
  yield stream.read()
99
 
100
+ # clean up
101
+ if os.exists(path_to_video):
102
+ os.remove(path_to_video)
103
+
104
 
105
  @spaces.GPU(duration=40)
106
  def estimate_depth(frame):