Spaces:
Running
on
L40S
Running
on
L40S
outputs .obj files
Browse files
app.py
CHANGED
@@ -125,8 +125,10 @@ def run_inference(temp_dir, removed_bg_path):
|
|
125 |
else:
|
126 |
print(f"\nThe folder '{specific_out_folder_path}' does not exist.")
|
127 |
|
128 |
-
|
129 |
-
|
|
|
|
|
130 |
except subprocess.CalledProcessError as e:
|
131 |
return f"Error during inference: {str(e)}"
|
132 |
|
@@ -143,7 +145,7 @@ def process_image(input_pil, remove_bg):
|
|
143 |
removed_bg_path, temp_dir = result # Unpack only if successful
|
144 |
|
145 |
# Run inference
|
146 |
-
output_video = run_inference(temp_dir, removed_bg_path)
|
147 |
|
148 |
if isinstance(output_video, str) and output_video.startswith("Error"):
|
149 |
shutil.rmtree(temp_dir)
|
@@ -153,7 +155,7 @@ def process_image(input_pil, remove_bg):
|
|
153 |
shutil.rmtree(temp_dir) # Cleanup temporary folder
|
154 |
print(output_video)
|
155 |
torch.cuda.empty_cache()
|
156 |
-
return output_video[0]
|
157 |
|
158 |
css="""
|
159 |
div#col-container{
|
@@ -201,8 +203,10 @@ def gradio_interface():
|
|
201 |
remove_bg = gr.Checkbox(label="Need to remove BG ?", value=False)
|
202 |
|
203 |
submit_button = gr.Button("Process")
|
204 |
-
|
205 |
-
|
|
|
|
|
206 |
|
207 |
gr.Examples(
|
208 |
examples = examples_folder,
|
@@ -210,7 +214,7 @@ def gradio_interface():
|
|
210 |
examples_per_page = 11
|
211 |
)
|
212 |
|
213 |
-
submit_button.click(process_image, inputs=[input_image, remove_bg], outputs=[output_video])
|
214 |
|
215 |
return app
|
216 |
|
|
|
125 |
else:
|
126 |
print(f"\nThe folder '{specific_out_folder_path}' does not exist.")
|
127 |
|
128 |
+
output_video = glob(os.path.join(f"out/{removed_bg_file_name}", "*.mp4"))
|
129 |
+
output_objects = glob(os.path.join(f"out/{removed_bg_file_name}", "*.obj"))
|
130 |
+
return output_video, output_objects
|
131 |
+
|
132 |
except subprocess.CalledProcessError as e:
|
133 |
return f"Error during inference: {str(e)}"
|
134 |
|
|
|
145 |
removed_bg_path, temp_dir = result # Unpack only if successful
|
146 |
|
147 |
# Run inference
|
148 |
+
output_video, output_objects = run_inference(temp_dir, removed_bg_path)
|
149 |
|
150 |
if isinstance(output_video, str) and output_video.startswith("Error"):
|
151 |
shutil.rmtree(temp_dir)
|
|
|
155 |
shutil.rmtree(temp_dir) # Cleanup temporary folder
|
156 |
print(output_video)
|
157 |
torch.cuda.empty_cache()
|
158 |
+
return output_video[0], output_objects
|
159 |
|
160 |
css="""
|
161 |
div#col-container{
|
|
|
203 |
remove_bg = gr.Checkbox(label="Need to remove BG ?", value=False)
|
204 |
|
205 |
submit_button = gr.Button("Process")
|
206 |
+
|
207 |
+
with gr.Column(scale=4):
|
208 |
+
output_video= gr.Video(label="Output Video", elem_id="video-out-elm")
|
209 |
+
output_objects = gr.Files(label=".OBJ outputs")
|
210 |
|
211 |
gr.Examples(
|
212 |
examples = examples_folder,
|
|
|
214 |
examples_per_page = 11
|
215 |
)
|
216 |
|
217 |
+
submit_button.click(process_image, inputs=[input_image, remove_bg], outputs=[output_video, output_objects])
|
218 |
|
219 |
return app
|
220 |
|