lidavidsh commited on
Commit
4422679
·
1 Parent(s): 8298de5

remove torch depends from frontend

Browse files
Files changed (1) hide show
  1. app.py +1 -8
app.py CHANGED
@@ -6,7 +6,6 @@
6
 
7
  import os
8
  import cv2
9
- import torch
10
  import numpy as np
11
  import gradio as gr
12
  import sys
@@ -95,7 +94,6 @@ def _get_result(job_id: str, token: str) -> dict:
95
  # -------------------------------------------------------------------------
96
  # 1) Core model inference (now forwards to remote service)
97
  # -------------------------------------------------------------------------
98
- @spaces.GPU(duration=120)
99
  def run_model(target_dir, model=None) -> dict:
100
  """
101
  Run the VGGT model on images in the 'target_dir/images' folder and return predictions.
@@ -189,7 +187,6 @@ def handle_uploads(input_video, input_images):
189
  """
190
  start_time = time.time()
191
  gc.collect()
192
- torch.cuda.empty_cache()
193
 
194
  # Create a unique folder name
195
  timestamp = datetime.now().strftime("%Y%m%d_%H%M%S_%f")
@@ -274,7 +271,6 @@ def update_gallery_on_upload(input_video, input_images):
274
  # -------------------------------------------------------------------------
275
  # 4) Reconstruction: uses the target_dir plus any viz parameters
276
  # -------------------------------------------------------------------------
277
- @spaces.GPU(duration=120)
278
  def gradio_demo(
279
  target_dir,
280
  conf_thres=3.0,
@@ -293,7 +289,6 @@ def gradio_demo(
293
 
294
  start_time = time.time()
295
  gc.collect()
296
- torch.cuda.empty_cache()
297
 
298
  # Prepare frame_filter dropdown
299
  target_dir_images = os.path.join(target_dir, "images")
@@ -306,8 +301,7 @@ def gradio_demo(
306
  frame_filter_choices = ["All"] + all_files
307
 
308
  print("Running run_model...")
309
- with torch.no_grad():
310
- predictions = run_model(target_dir)
311
 
312
  # Save predictions
313
  prediction_save_path = os.path.join(target_dir, "predictions.npz")
@@ -340,7 +334,6 @@ def gradio_demo(
340
  # Cleanup
341
  del predictions
342
  gc.collect()
343
- torch.cuda.empty_cache()
344
 
345
  end_time = time.time()
346
  print(f"Total time: {end_time - start_time:.2f} seconds")
 
6
 
7
  import os
8
  import cv2
 
9
  import numpy as np
10
  import gradio as gr
11
  import sys
 
94
  # -------------------------------------------------------------------------
95
  # 1) Core model inference (now forwards to remote service)
96
  # -------------------------------------------------------------------------
 
97
  def run_model(target_dir, model=None) -> dict:
98
  """
99
  Run the VGGT model on images in the 'target_dir/images' folder and return predictions.
 
187
  """
188
  start_time = time.time()
189
  gc.collect()
 
190
 
191
  # Create a unique folder name
192
  timestamp = datetime.now().strftime("%Y%m%d_%H%M%S_%f")
 
271
  # -------------------------------------------------------------------------
272
  # 4) Reconstruction: uses the target_dir plus any viz parameters
273
  # -------------------------------------------------------------------------
 
274
  def gradio_demo(
275
  target_dir,
276
  conf_thres=3.0,
 
289
 
290
  start_time = time.time()
291
  gc.collect()
 
292
 
293
  # Prepare frame_filter dropdown
294
  target_dir_images = os.path.join(target_dir, "images")
 
301
  frame_filter_choices = ["All"] + all_files
302
 
303
  print("Running run_model...")
304
+ predictions = run_model(target_dir)
 
305
 
306
  # Save predictions
307
  prediction_save_path = os.path.join(target_dir, "predictions.npz")
 
334
  # Cleanup
335
  del predictions
336
  gc.collect()
 
337
 
338
  end_time = time.time()
339
  print(f"Total time: {end_time - start_time:.2f} seconds")