Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -310,17 +310,6 @@ css = """
|
|
310 |
}
|
311 |
"""
|
312 |
|
313 |
-
js = """
|
314 |
-
var iv = setInterval(function() {
|
315 |
-
try {
|
316 |
-
if (BABYLON && BABYLON.Engine.LastCreatedScene.getNodes()[1].material.pointSize) {
|
317 |
-
alert(BABYLON.Engine.LastCreatedScene.getNodes()[1].material.pointSize);
|
318 |
-
clearInterval(iv);
|
319 |
-
}
|
320 |
-
} catch(e) {}
|
321 |
-
}, 1000);
|
322 |
-
"""
|
323 |
-
|
324 |
title = "# Depth Anything Video Demo"
|
325 |
description = """Depth Anything on full video files.
|
326 |
Please refer to our [paper](https://arxiv.org/abs/2401.10891), [project page](https://depth-anything.github.io), or [github](https://github.com/LiheYoung/Depth-Anything) for more details.
|
@@ -344,7 +333,7 @@ transform = Compose([
|
|
344 |
# def predict_depth(model, image):
|
345 |
# return model(image)
|
346 |
|
347 |
-
with gr.Blocks(css=css
|
348 |
gr.Markdown(title)
|
349 |
gr.Markdown(description)
|
350 |
gr.Markdown("### Video Depth Prediction demo")
|
@@ -434,50 +423,54 @@ with gr.Blocks(css=css, js=js) as demo:
|
|
434 |
this.parentNode.childNodes[2].innerText = this.value;
|
435 |
'/><span>1</span>""")
|
436 |
blur_in = gr.Textbox(value="", label="Blur kernel size")
|
437 |
-
html = gr.HTML(value="""<label for='zoom'>Zoom</label><input id='zoom' type='range' style='width:256px;height:1em;' min='0.157' max='1.57' step='0.001' oninput='
|
|
|
|
|
|
|
|
|
|
|
438 |
BABYLON.Engine.LastCreatedScene.getNodes()[1].material.pointSize = Math.ceil(Math.log2(Math.PI/this.value));
|
439 |
-
|
|
|
|
|
|
|
440 |
if (!BABYLON.Engine.LastCreatedScene.activeCamera.metadata) {
|
441 |
BABYLON.Engine.LastCreatedScene.activeCamera.metadata = {
|
442 |
screenshot: true,
|
443 |
pipeline: new BABYLON.DefaultRenderingPipeline(\"default\", true, BABYLON.Engine.LastCreatedScene, [BABYLON.Engine.LastCreatedScene.activeCamera])
|
444 |
}
|
445 |
}
|
|
|
|
|
446 |
BABYLON.Engine.LastCreatedScene.activeCamera.metadata.pipeline.samples = 4;
|
447 |
-
BABYLON.Engine.LastCreatedScene.activeCamera.
|
448 |
-
|
449 |
|
450 |
document.getElementsByClassName(\"model3D\")[0].getElementsByTagName(\"canvas\")[0].style.filter = \"blur(\" + BABYLON.Engine.LastCreatedScene.getNodes()[1].material.pointSize/Math.sqrt(2.0)/2.0 + \"px)\";
|
451 |
-
'
|
452 |
-
camera = gr.HTML(value="<a href='#' onclick=\"BABYLON.Engine.LastCreatedScene.activeCamera.radius=0;\">reset camera</a>")
|
453 |
contrast = gr.HTML(value="""<label for='contrast'>Contrast</label><input id='contrast' type='range' style='width:256px;height:1em;' value='2.0' min='0' max='2' step='0.001' oninput='
|
454 |
if (!BABYLON.Engine.LastCreatedScene.activeCamera.metadata) {
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
}
|
459 |
}
|
460 |
-
BABYLON.Engine.LastCreatedScene.activeCamera.metadata.pipeline.samples = 4;
|
461 |
BABYLON.Engine.LastCreatedScene.activeCamera.metadata.pipeline.imageProcessing.contrast = this.value;
|
462 |
this.parentNode.childNodes[2].innerText = BABYLON.Engine.LastCreatedScene.activeCamera.metadata.pipeline.imageProcessing.contrast;
|
463 |
'/><span>2.0</span>""")
|
464 |
exposure = gr.HTML(value="""<label for='exposure'>Exposure</label><input id='exposure' type='range' style='width:256px;height:1em;' value='0.5' min='0' max='2' step='0.001' oninput='
|
465 |
if (!BABYLON.Engine.LastCreatedScene.activeCamera.metadata) {
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
}
|
470 |
}
|
471 |
-
BABYLON.Engine.LastCreatedScene.activeCamera.metadata.pipeline.samples = 4;
|
472 |
BABYLON.Engine.LastCreatedScene.activeCamera.metadata.pipeline.imageProcessing.exposure = this.value;
|
473 |
this.parentNode.childNodes[2].innerText = BABYLON.Engine.LastCreatedScene.activeCamera.metadata.pipeline.imageProcessing.exposure;
|
474 |
'/><span>0.5</span>""")
|
475 |
canvas = gr.HTML(value="""<a href='#' onclick='
|
476 |
if (!BABYLON.Engine.LastCreatedScene.activeCamera.metadata) {
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
}
|
481 |
}
|
482 |
//var cntxt = document.getElementsByClassName(\"model3D\")[0].getElementsByTagName(\"canvas\")[0].getContext(\"webgl2\");
|
483 |
//this.innerText = cntxt;
|
|
|
310 |
}
|
311 |
"""
|
312 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
313 |
title = "# Depth Anything Video Demo"
|
314 |
description = """Depth Anything on full video files.
|
315 |
Please refer to our [paper](https://arxiv.org/abs/2401.10891), [project page](https://depth-anything.github.io), or [github](https://github.com/LiheYoung/Depth-Anything) for more details.
|
|
|
333 |
# def predict_depth(model, image):
|
334 |
# return model(image)
|
335 |
|
336 |
+
with gr.Blocks(css=css) as demo:
|
337 |
gr.Markdown(title)
|
338 |
gr.Markdown(description)
|
339 |
gr.Markdown("### Video Depth Prediction demo")
|
|
|
423 |
this.parentNode.childNodes[2].innerText = this.value;
|
424 |
'/><span>1</span>""")
|
425 |
blur_in = gr.Textbox(value="", label="Blur kernel size")
|
426 |
+
html = gr.HTML(value="""<label for='zoom'>Zoom</label><input id='zoom' type='range' style='width:256px;height:1em;' value='0.8' min='0.157' max='1.57' step='0.001' oninput='
|
427 |
+
if (!BABYLON.Engine.LastCreatedScene.activeCamera.metadata) {
|
428 |
+
var evt = document.createEvent(\"Event\");
|
429 |
+
evt.initEvent(\"click\", true, false);
|
430 |
+
document.getElementById(\"reset_cam\").dispatchEvent(evt);
|
431 |
+
}
|
432 |
BABYLON.Engine.LastCreatedScene.getNodes()[1].material.pointSize = Math.ceil(Math.log2(Math.PI/this.value));
|
433 |
+
BABYLON.Engine.LastCreatedScene.activeCamera.fov = this.value;
|
434 |
+
this.parentNode.childNodes[2].innerText = BABYLON.Engine.LastCreatedScene.activeCamera.fov;
|
435 |
+
'/><span>0.8</span>""")
|
436 |
+
camera = gr.HTML(value="""<a href='#' id='reset_cam' onclick='
|
437 |
if (!BABYLON.Engine.LastCreatedScene.activeCamera.metadata) {
|
438 |
BABYLON.Engine.LastCreatedScene.activeCamera.metadata = {
|
439 |
screenshot: true,
|
440 |
pipeline: new BABYLON.DefaultRenderingPipeline(\"default\", true, BABYLON.Engine.LastCreatedScene, [BABYLON.Engine.LastCreatedScene.activeCamera])
|
441 |
}
|
442 |
}
|
443 |
+
BABYLON.Engine.LastCreatedScene.activeCamera.radius = 0;
|
444 |
+
BABYLON.Engine.LastCreatedScene.getNodes()[1].material.pointSize = Math.ceil(Math.log2(Math.PI/document.getElementById(\"zoom\").value));
|
445 |
BABYLON.Engine.LastCreatedScene.activeCamera.metadata.pipeline.samples = 4;
|
446 |
+
BABYLON.Engine.LastCreatedScene.activeCamera.metadata.pipeline.imageProcessing.contrast = document.getElementById(\"contrast\").value;
|
447 |
+
BABYLON.Engine.LastCreatedScene.activeCamera.metadata.pipeline.imageProcessing.exposure = document.getElementById(\"exposure\").value;
|
448 |
|
449 |
document.getElementsByClassName(\"model3D\")[0].getElementsByTagName(\"canvas\")[0].style.filter = \"blur(\" + BABYLON.Engine.LastCreatedScene.getNodes()[1].material.pointSize/Math.sqrt(2.0)/2.0 + \"px)\";
|
450 |
+
'>reset camera</a>""")
|
|
|
451 |
contrast = gr.HTML(value="""<label for='contrast'>Contrast</label><input id='contrast' type='range' style='width:256px;height:1em;' value='2.0' min='0' max='2' step='0.001' oninput='
|
452 |
if (!BABYLON.Engine.LastCreatedScene.activeCamera.metadata) {
|
453 |
+
var evt = document.createEvent(\"Event\");
|
454 |
+
evt.initEvent(\"click\", true, false);
|
455 |
+
document.getElementById(\"reset_cam\").dispatchEvent(evt);
|
|
|
456 |
}
|
|
|
457 |
BABYLON.Engine.LastCreatedScene.activeCamera.metadata.pipeline.imageProcessing.contrast = this.value;
|
458 |
this.parentNode.childNodes[2].innerText = BABYLON.Engine.LastCreatedScene.activeCamera.metadata.pipeline.imageProcessing.contrast;
|
459 |
'/><span>2.0</span>""")
|
460 |
exposure = gr.HTML(value="""<label for='exposure'>Exposure</label><input id='exposure' type='range' style='width:256px;height:1em;' value='0.5' min='0' max='2' step='0.001' oninput='
|
461 |
if (!BABYLON.Engine.LastCreatedScene.activeCamera.metadata) {
|
462 |
+
var evt = document.createEvent(\"Event\");
|
463 |
+
evt.initEvent(\"click\", true, false);
|
464 |
+
document.getElementById(\"reset_cam\").dispatchEvent(evt);
|
|
|
465 |
}
|
|
|
466 |
BABYLON.Engine.LastCreatedScene.activeCamera.metadata.pipeline.imageProcessing.exposure = this.value;
|
467 |
this.parentNode.childNodes[2].innerText = BABYLON.Engine.LastCreatedScene.activeCamera.metadata.pipeline.imageProcessing.exposure;
|
468 |
'/><span>0.5</span>""")
|
469 |
canvas = gr.HTML(value="""<a href='#' onclick='
|
470 |
if (!BABYLON.Engine.LastCreatedScene.activeCamera.metadata) {
|
471 |
+
var evt = document.createEvent(\"Event\");
|
472 |
+
evt.initEvent(\"click\", true, false);
|
473 |
+
document.getElementById(\"reset_cam\").dispatchEvent(evt);
|
|
|
474 |
}
|
475 |
//var cntxt = document.getElementsByClassName(\"model3D\")[0].getElementsByTagName(\"canvas\")[0].getContext(\"webgl2\");
|
476 |
//this.innerText = cntxt;
|