Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -112,6 +112,23 @@ with gr.Blocks(js=js, css=css) as demo:
|
|
112 |
depth_image_slider = ImageSlider(label="Depth Map with Slider View", elem_id='img-display-output', position=0.5)
|
113 |
gray_depth_file = gr.File(label="Grayscale depth map", elem_id="download",)
|
114 |
submit = gr.Button(value="Compute Depth")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
with gr.Tab("Normals"):
|
116 |
normals_out = gr.Image(label="Normal map", interactive=False)
|
117 |
format_normals = gr.Radio(choices=["directx", "opengl"])
|
@@ -138,23 +155,6 @@ with gr.Blocks(js=js, css=css) as demo:
|
|
138 |
colored_depth = (cmap(depth)[:, :, :3] * 255).astype(np.uint8)
|
139 |
|
140 |
gray_depth = Image.fromarray(depth)
|
141 |
-
svg = gr.HTML("""
|
142 |
-
<svg id='svg'
|
143 |
-
width='1024'
|
144 |
-
height='512'
|
145 |
-
viewBox='0 0 1024 512'
|
146 |
-
xmlns='http://www.w3.org/2000/svg'>
|
147 |
-
<style></style>
|
148 |
-
<filter id='displacementFilter' color-interpolation-filters='sRGB'>
|
149 |
-
<feImage id='feimage' crossorigin='anonymous' width='100%' height='100%' x='0' y='0' result='10_MAP' href='https://freeali.se/panoramera/examples/basic/f0_dmap_.png'/>
|
150 |
-
<feGaussianBlur result='blurred' in='10_MAP' stdDeviation='15,15' />
|
151 |
-
<feDisplacementMap id='dmap' result='fedm' in2='blurred' in='SourceGraphic' scale='2' xChannelSelector='G' yChannelSelector='A' />
|
152 |
-
</filter>
|
153 |
-
<image id='inimage' crossorigin='anonymous' href='https://freeali.se/panoramera/examples/basic/f0.jpg' x='0' y='0' height='100%' width='100%' style='filter: url(#displacementFilter)'/>
|
154 |
-
</svg>
|
155 |
-
""")
|
156 |
-
scale = gr.Slider(label="Scale", minimum="-128", maximum="128", value="0", step="1", elem_id="scale")
|
157 |
-
gray_depth_file.change(fn=None, inputs=[input_image, gray_depth_file], outputs=None, js=load_svg)
|
158 |
tmp_gray_depth = tempfile.NamedTemporaryFile(suffix='.png', delete=False)
|
159 |
gray_depth.save(tmp_gray_depth.name)
|
160 |
|
|
|
112 |
depth_image_slider = ImageSlider(label="Depth Map with Slider View", elem_id='img-display-output', position=0.5)
|
113 |
gray_depth_file = gr.File(label="Grayscale depth map", elem_id="download",)
|
114 |
submit = gr.Button(value="Compute Depth")
|
115 |
+
svg = gr.HTML("""
|
116 |
+
<svg id='svg'
|
117 |
+
width='1024'
|
118 |
+
height='512'
|
119 |
+
viewBox='0 0 1024 512'
|
120 |
+
xmlns='http://www.w3.org/2000/svg'>
|
121 |
+
<style></style>
|
122 |
+
<filter id='displacementFilter' color-interpolation-filters='sRGB'>
|
123 |
+
<feImage id='feimage' crossorigin='anonymous' width='100%' height='100%' x='0' y='0' result='10_MAP' href='https://freeali.se/panoramera/examples/basic/f0_dmap_.png'/>
|
124 |
+
<feGaussianBlur result='blurred' in='10_MAP' stdDeviation='15,15' />
|
125 |
+
<feDisplacementMap id='dmap' result='fedm' in2='blurred' in='SourceGraphic' scale='2' xChannelSelector='G' yChannelSelector='A' />
|
126 |
+
</filter>
|
127 |
+
<image id='inimage' crossorigin='anonymous' href='https://freeali.se/panoramera/examples/basic/f0.jpg' x='0' y='0' height='100%' width='100%' style='filter: url(#displacementFilter)'/>
|
128 |
+
</svg>
|
129 |
+
""")
|
130 |
+
scale = gr.Slider(label="Scale", minimum="-128", maximum="128", value="0", step="1", elem_id="scale")
|
131 |
+
gray_depth_file.change(fn=None, inputs=[input_image, gray_depth_file], outputs=None, js=load_svg)
|
132 |
with gr.Tab("Normals"):
|
133 |
normals_out = gr.Image(label="Normal map", interactive=False)
|
134 |
format_normals = gr.Radio(choices=["directx", "opengl"])
|
|
|
155 |
colored_depth = (cmap(depth)[:, :, :3] * 255).astype(np.uint8)
|
156 |
|
157 |
gray_depth = Image.fromarray(depth)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
tmp_gray_depth = tempfile.NamedTemporaryFile(suffix='.png', delete=False)
|
159 |
gray_depth.save(tmp_gray_depth.name)
|
160 |
|