Spaces:
Running
on
L40S
Running
on
L40S
Update app.py
Browse files
app.py
CHANGED
@@ -81,7 +81,7 @@ def run_inference(temp_dir):
|
|
81 |
)
|
82 |
|
83 |
# Collect the output images
|
84 |
-
output_images = glob(os.path.join(
|
85 |
return output_images
|
86 |
except subprocess.CalledProcessError as e:
|
87 |
return f"Error during inference: {str(e)}"
|
@@ -96,19 +96,15 @@ def process_image(input_url):
|
|
96 |
removed_bg_path, temp_dir = result # Unpack only if successful
|
97 |
|
98 |
# Run inference
|
99 |
-
|
100 |
|
101 |
-
if isinstance(
|
102 |
shutil.rmtree(temp_dir)
|
103 |
raise gr.Error(f"{output_images}") # Return the error message if inference failed
|
104 |
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
results.append((img_path, img_path))
|
109 |
-
|
110 |
-
#shutil.rmtree(temp_dir) # Cleanup temporary folder
|
111 |
-
return results
|
112 |
|
113 |
def gradio_interface():
|
114 |
with gr.Blocks() as app:
|
@@ -118,9 +114,9 @@ def gradio_interface():
|
|
118 |
input_image = gr.Image(label="Image input", type="filepath")
|
119 |
submit_button = gr.Button("Process")
|
120 |
|
121 |
-
|
122 |
|
123 |
-
submit_button.click(process_image, inputs=[input_image], outputs=[
|
124 |
|
125 |
return app
|
126 |
|
|
|
81 |
)
|
82 |
|
83 |
# Collect the output images
|
84 |
+
output_images = glob(os.path.join("mv_results", "*.mp4"))
|
85 |
return output_images
|
86 |
except subprocess.CalledProcessError as e:
|
87 |
return f"Error during inference: {str(e)}"
|
|
|
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)
|
103 |
raise gr.Error(f"{output_images}") # Return the error message if inference failed
|
104 |
|
105 |
+
|
106 |
+
shutil.rmtree(temp_dir) # Cleanup temporary folder
|
107 |
+
return output_video
|
|
|
|
|
|
|
|
|
108 |
|
109 |
def gradio_interface():
|
110 |
with gr.Blocks() as app:
|
|
|
114 |
input_image = gr.Image(label="Image input", type="filepath")
|
115 |
submit_button = gr.Button("Process")
|
116 |
|
117 |
+
output_video= gr.Video(label="Output Video")
|
118 |
|
119 |
+
submit_button.click(process_image, inputs=[input_image], outputs=[output_video])
|
120 |
|
121 |
return app
|
122 |
|