freealise commited on
Commit
11e9611
1 Parent(s): d72f154

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -13
app.py CHANGED
@@ -311,15 +311,6 @@ css = """
311
  """
312
 
313
  js = """
314
- var txtr = document.getElementsByTagName(\"textarea\")[1];
315
- txtr.parentNode.onclick = function(event) {
316
- if (txtr.style.display != 'block')
317
- txtr.style.display = 'block';
318
- } else {
319
- txtr.style.display = 'none';
320
- }
321
- }
322
- txtr.style.display = 'none';
323
  """
324
 
325
  title = "# Depth Anything Video Demo"
@@ -450,7 +441,9 @@ with gr.Blocks(css=css, js=js) as demo:
450
  ' oninput='
451
  this.parentNode.childNodes[2].innerText = this.value;
452
  '/><span>1</span>""")
453
- blur_in = gr.Textbox(value="", label="Blur kernel size")
 
 
454
  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='
455
  if (!BABYLON.Engine.LastCreatedScene.activeCamera.metadata) {
456
  var evt = document.createEvent(\"Event\");
@@ -510,7 +503,6 @@ with gr.Blocks(css=css, js=js) as demo:
510
  try {
511
  BABYLON.Tools.CreateScreenshotUsingRenderTarget(BABYLON.Engine.LastCreatedScene.getEngine(), BABYLON.Engine.LastCreatedScene.activeCamera,
512
  { precision: 1.0 }, (durl) => {
513
- document.getElementById(\"img_out\").src = durl;
514
  document.getElementById(\"img_out\").onload = function() {
515
  var svgd = `<svg id=\"svg_out\" viewBox=\"0 0 ` + document.getElementById(\"img_out\").width + ` ` + document.getElementById(\"img_out\").height + `\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">
516
  <defs>
@@ -520,20 +512,21 @@ with gr.Blocks(css=css, js=js) as demo:
520
  </defs>
521
  <image filter=\"url(#blur)\" id=\"svg_img\" x=\"0\" y=\"0\" width=\"` + document.getElementById(\"img_out\").width + `\" height=\"` + document.getElementById(\"img_out\").height + `\" xlink:href=\"` + durl + `\"/>
522
  </svg>`;
523
- document.getElementById(\"img_out\").src = \"data:image/svg+xml;base64,\" + btoa(svgd);
524
  document.getElementById(\"img_out\").onload = function() {
525
  document.getElementById(\"cnv_out\").width = document.getElementById(\"img_out\").width;
526
  document.getElementById(\"cnv_out\").height = document.getElementById(\"img_out\").height;
527
  document.getElementById(\"cnv_out\").getContext(\"2d\").drawImage(img_out, 0, 0);
528
  }
 
529
  }
 
530
  }
531
  );
532
  } catch(e) { alert(e); }
533
  // https://forum.babylonjs.com/t/best-way-to-save-to-jpeg-snapshots-of-scene/17663/11
534
  }
535
  });
536
- '/>webgl2</a><br/><img src='' id='img_out'/><br/>
537
  <canvas id='cnv_out'/>""")
538
  render = gr.Button("Render")
539
 
 
311
  """
312
 
313
  js = """
 
 
 
 
 
 
 
 
 
314
  """
315
 
316
  title = "# Depth Anything Video Demo"
 
441
  ' oninput='
442
  this.parentNode.childNodes[2].innerText = this.value;
443
  '/><span>1</span>""")
444
+ with gr.Accordion(label="Blur levels", open=False):
445
+ blur_in = gr.Textbox(value="", label="Kernel size", show_label=False)
446
+
447
  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='
448
  if (!BABYLON.Engine.LastCreatedScene.activeCamera.metadata) {
449
  var evt = document.createEvent(\"Event\");
 
503
  try {
504
  BABYLON.Tools.CreateScreenshotUsingRenderTarget(BABYLON.Engine.LastCreatedScene.getEngine(), BABYLON.Engine.LastCreatedScene.activeCamera,
505
  { precision: 1.0 }, (durl) => {
 
506
  document.getElementById(\"img_out\").onload = function() {
507
  var svgd = `<svg id=\"svg_out\" viewBox=\"0 0 ` + document.getElementById(\"img_out\").width + ` ` + document.getElementById(\"img_out\").height + `\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">
508
  <defs>
 
512
  </defs>
513
  <image filter=\"url(#blur)\" id=\"svg_img\" x=\"0\" y=\"0\" width=\"` + document.getElementById(\"img_out\").width + `\" height=\"` + document.getElementById(\"img_out\").height + `\" xlink:href=\"` + durl + `\"/>
514
  </svg>`;
 
515
  document.getElementById(\"img_out\").onload = function() {
516
  document.getElementById(\"cnv_out\").width = document.getElementById(\"img_out\").width;
517
  document.getElementById(\"cnv_out\").height = document.getElementById(\"img_out\").height;
518
  document.getElementById(\"cnv_out\").getContext(\"2d\").drawImage(img_out, 0, 0);
519
  }
520
+ document.getElementById(\"img_out\").src = \"data:image/svg+xml;base64,\" + btoa(svgd);
521
  }
522
+ document.getElementById(\"img_out\").src = durl;
523
  }
524
  );
525
  } catch(e) { alert(e); }
526
  // https://forum.babylonjs.com/t/best-way-to-save-to-jpeg-snapshots-of-scene/17663/11
527
  }
528
  });
529
+ '/>snapshot</a><br/><img src='' id='img_out'/><br/>
530
  <canvas id='cnv_out'/>""")
531
  render = gr.Button("Render")
532