Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -74,25 +74,6 @@ def findNormals(gray_depth, format):
|
|
74 |
return (normal[:, :, ::-1]).astype(np.uint8)
|
75 |
|
76 |
|
77 |
-
js="""
|
78 |
-
async()=>{
|
79 |
-
document.getElementById('scale').addEventListener('input', displace);
|
80 |
-
|
81 |
-
function displace(e) {
|
82 |
-
document.getElementById('dmap').setAttributeNS(null, 'scale', ''+e.target.value);
|
83 |
-
}
|
84 |
-
|
85 |
-
document.getElementById('img-display-output').getElementsByTagName('img')[1].onload = function(e) {
|
86 |
-
document.getElementById('feimage').outerHTML = '<feImage id="feimage" crossorigin="anonymous" width="100%" height="100%" x="0" y="0" result="10_MAP" href="' + e.target.src + '"/>';
|
87 |
-
}
|
88 |
-
|
89 |
-
document.getElementById('img-display-output').getElementsByTagName('img')[0].onload = function(e) {
|
90 |
-
document.getElementById('inimage').outerHTML = '<image id="inimage" crossorigin="anonymous" href="' + e.target.src + '" x="0" y="0" height="100%" width="100%" style="filter: url(#displacementFilter)"/>';
|
91 |
-
}
|
92 |
-
}
|
93 |
-
"""
|
94 |
-
|
95 |
-
|
96 |
title = "# Depth Anything V2"
|
97 |
description = """Unofficial demo for **Depth Anything V2**.
|
98 |
Please refer to their [paper](https://arxiv.org/abs/2406.09414), [project page](https://depth-anything-v2.github.io), and [github](https://github.com/DepthAnything/Depth-Anything-V2) for more details."""
|
@@ -101,7 +82,7 @@ Please refer to their [paper](https://arxiv.org/abs/2406.09414), [project page](
|
|
101 |
def predict_depth(image):
|
102 |
return model.infer_image(image)
|
103 |
|
104 |
-
with gr.Blocks(
|
105 |
gr.Markdown(title)
|
106 |
gr.Markdown(description)
|
107 |
gr.Markdown("### Depth Prediction demo")
|
@@ -113,22 +94,6 @@ with gr.Blocks(js=js, css=css) as demo:
|
|
113 |
orig_image_file = gr.File(label="Original image", elem_id="original")
|
114 |
gray_depth_file = gr.File(label="Grayscale depth map", elem_id="download")
|
115 |
submit = gr.Button(value="Compute Depth")
|
116 |
-
svg = gr.HTML("""
|
117 |
-
<svg id='svg'
|
118 |
-
width='1024'
|
119 |
-
height='512'
|
120 |
-
viewBox='0 0 1024 512'
|
121 |
-
xmlns='http://www.w3.org/2000/svg'>
|
122 |
-
<style></style>
|
123 |
-
<filter id='displacementFilter' color-interpolation-filters='sRGB'>
|
124 |
-
<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'/>
|
125 |
-
<feGaussianBlur result='blurred' in='10_MAP' stdDeviation='15,15' />
|
126 |
-
<feDisplacementMap id='dmap' result='fedm' in2='blurred' in='SourceGraphic' scale='2' xChannelSelector='G' yChannelSelector='A' />
|
127 |
-
</filter>
|
128 |
-
<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)'/>
|
129 |
-
</svg><br/>
|
130 |
-
<input type='range' min='-128' max='128' value='0' step='1' id='scale'/>
|
131 |
-
""")
|
132 |
with gr.Tab("Normals"):
|
133 |
normals_out = gr.Image(label="Normal map", interactive=False)
|
134 |
format_normals = gr.Radio(choices=["directx", "opengl"])
|
|
|
74 |
return (normal[:, :, ::-1]).astype(np.uint8)
|
75 |
|
76 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
title = "# Depth Anything V2"
|
78 |
description = """Unofficial demo for **Depth Anything V2**.
|
79 |
Please refer to their [paper](https://arxiv.org/abs/2406.09414), [project page](https://depth-anything-v2.github.io), and [github](https://github.com/DepthAnything/Depth-Anything-V2) for more details."""
|
|
|
82 |
def predict_depth(image):
|
83 |
return model.infer_image(image)
|
84 |
|
85 |
+
with gr.Blocks(css=css) as demo:
|
86 |
gr.Markdown(title)
|
87 |
gr.Markdown(description)
|
88 |
gr.Markdown("### Depth Prediction demo")
|
|
|
94 |
orig_image_file = gr.File(label="Original image", elem_id="original")
|
95 |
gray_depth_file = gr.File(label="Grayscale depth map", elem_id="download")
|
96 |
submit = gr.Button(value="Compute Depth")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
with gr.Tab("Normals"):
|
98 |
normals_out = gr.Image(label="Normal map", interactive=False)
|
99 |
format_normals = gr.Radio(choices=["directx", "opengl"])
|