fffiloni commited on
Commit
67aa81a
1 Parent(s): 6ec3acd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -54,7 +54,7 @@ def remove_background(input_url):
54
 
55
  return removed_bg_path, temp_dir
56
 
57
- def run_inference(temp_dir):
58
  # Define the inference configuration
59
  inference_config = "configs/inference-768-6view.yaml"
60
  pretrained_model = "./ckpts"
@@ -80,9 +80,11 @@ def run_inference(temp_dir):
80
  check=True
81
  )
82
 
83
- # Collect the output images
84
- output_images = glob(os.path.join("out/input_image", "*.mp4"))
85
- return output_images
 
 
86
  except subprocess.CalledProcessError as e:
87
  return f"Error during inference: {str(e)}"
88
 
@@ -96,7 +98,7 @@ def process_image(input_url):
96
  removed_bg_path, temp_dir = result # Unpack only if successful
97
 
98
  # Run inference
99
- output_video = run_inference(temp_dir)
100
 
101
  if isinstance(output_video, str) and output_video.startswith("Error"):
102
  shutil.rmtree(temp_dir)
 
54
 
55
  return removed_bg_path, temp_dir
56
 
57
+ def run_inference(temp_dir, removed_bg_path):
58
  # Define the inference configuration
59
  inference_config = "configs/inference-768-6view.yaml"
60
  pretrained_model = "./ckpts"
 
80
  check=True
81
  )
82
 
83
+
84
+ # Retrieve the file name
85
+ removed_bg_file_name = os.path.basename(removed_bg_path)
86
+ output_videos = glob(os.path.join(f"out/{removed_bg_file_name}", "*.mp4"))
87
+ return output_videos
88
  except subprocess.CalledProcessError as e:
89
  return f"Error during inference: {str(e)}"
90
 
 
98
  removed_bg_path, temp_dir = result # Unpack only if successful
99
 
100
  # Run inference
101
+ output_video = run_inference(temp_dir, removed_bg_path)
102
 
103
  if isinstance(output_video, str) and output_video.startswith("Error"):
104
  shutil.rmtree(temp_dir)