Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -84,26 +84,14 @@ with gr.Blocks(css=css) as demo:
|
|
84 |
|
85 |
depth = predict_depth(image)
|
86 |
|
87 |
-
|
88 |
-
tmp_raw_depth = tempfile.NamedTemporaryFile(suffix='.png', delete=False)
|
89 |
-
raw_depth.save(tmp_raw_depth.name)
|
90 |
-
|
91 |
-
depth = (depth - depth.min()) / (depth.max() - depth.min()) * 255.0
|
92 |
-
depth = depth.astype(np.uint8)
|
93 |
-
colored_depth = (cmap(depth)[:, :, :3] * 255).astype(np.uint8)
|
94 |
-
|
95 |
-
gray_depth = Image.fromarray(depth)
|
96 |
-
tmp_gray_depth = tempfile.NamedTemporaryFile(suffix='.png', delete=False)
|
97 |
-
gray_depth.save(tmp_gray_depth.name)
|
98 |
-
|
99 |
-
return [(original_image, colored_depth), tmp_gray_depth.name, tmp_raw_depth.name]
|
100 |
|
101 |
submit.click(on_submit, inputs=[input_image], outputs=[depth_image_slider, gray_depth_file, raw_file])
|
102 |
|
103 |
example_files = os.listdir('assets/examples')
|
104 |
example_files.sort()
|
105 |
example_files = [os.path.join('assets/examples', filename) for filename in example_files]
|
106 |
-
examples = gr.Examples(examples=example_files, inputs=[input_image], outputs=[depth_image_slider
|
107 |
|
108 |
|
109 |
if __name__ == '__main__':
|
|
|
84 |
|
85 |
depth = predict_depth(image)
|
86 |
|
87 |
+
return [(original_image, depth)]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
|
89 |
submit.click(on_submit, inputs=[input_image], outputs=[depth_image_slider, gray_depth_file, raw_file])
|
90 |
|
91 |
example_files = os.listdir('assets/examples')
|
92 |
example_files.sort()
|
93 |
example_files = [os.path.join('assets/examples', filename) for filename in example_files]
|
94 |
+
examples = gr.Examples(examples=example_files, inputs=[input_image], outputs=[depth_image_slider], fn=on_submit)
|
95 |
|
96 |
|
97 |
if __name__ == '__main__':
|