freealise commited on
Commit
875e86b
1 Parent(s): 828e1fe

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -40
app.py CHANGED
@@ -410,6 +410,46 @@ with gr.Blocks(css=css) as demo:
410
  output_switch = gr.Checkbox(label="Show depths")
411
  output_switch.input(fn=switch_rows, inputs=[output_switch], outputs=[output_frame])
412
  output_mask = gr.ImageEditor(layers=True, sources=None, type="numpy", interactive=True, transforms=(None,), eraser=gr.Eraser(), brush=gr.Brush(default_size=0, colors=['black', '#505050', '#a0a0a0', 'white']), elem_id="image_edit")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
413
  submit = gr.Button("Submit")
414
  with gr.Column():
415
  model_type = gr.Dropdown([("small", "vits"), ("base", "vitb"), ("large", "vitl")], type="value", value="vits", label='Model Type')
@@ -688,46 +728,6 @@ with gr.Blocks(css=css) as demo:
688
  BABYLON.Engine.LastCreatedScene.activeCamera.metadata.gizmoManager.attachToMesh(BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1]);
689
 
690
  '>reset camera</a>""")
691
- mouse = gr.Textbox(elem_id="mouse", value="""0, 0, 0, 0""")
692
- output_mask.apply(fn=draw_mask, inputs=[mouse, output_mask], outputs=[output_mask])
693
- selector = gr.HTML(value="""<div id='select_frame' style='position:absolute;border:1px dashed #808080;width:0;height:0'></div>
694
- <input type='number' id='mousedown' style='color:auto;background-color:transparent;border:1px solid lightgray;'/>
695
- <input type='number' id='mouseup' style='color:auto;background-color:transparent;border:1px solid lightgray;'/>
696
- <a href='#' id='selector' onclick='
697
- document.body.appendChild(document.getElementById(\"select_frame\"));
698
- document.getElementById(\"image_edit\").getElementsByTagName(\"canvas\")[0].onpointerdown = function(e) {
699
- var x = parseInt((e.clientX-e.target.getBoundingClientRect().x)*e.target.width/e.target.getBoundingClientRect().width);
700
- var y = parseInt((e.clientY-e.target.getBoundingClientRect().y)*e.target.height/e.target.getBoundingClientRect().height);
701
- document.getElementById(\"mousedown\").value = x + y / 10000;
702
-
703
- document.getElementById(\"select_frame\").style.left = 0;
704
- document.getElementById(\"select_frame\").style.width = 0;
705
- document.getElementById(\"select_frame\").style.top = 0;
706
- document.getElementById(\"select_frame\").style.height = 0;
707
- }
708
- document.getElementById(\"image_edit\").getElementsByTagName(\"canvas\")[0].onpointerup = function(e) {
709
- var x = parseInt((e.clientX-e.target.getBoundingClientRect().x)*e.target.width/e.target.getBoundingClientRect().width);
710
- var y = parseInt((e.clientY-e.target.getBoundingClientRect().y)*e.target.height/e.target.getBoundingClientRect().height);
711
- document.getElementById(\"mouseup\").value = x + y / 10000;
712
-
713
- var x0 = parseInt(document.getElementById(\"mousedown\").value);
714
- var x1 = parseInt(document.getElementById(\"mouseup\").value);
715
- var y0 = parseInt((parseFloat(document.getElementById(\"mousedown\").value)-x0)*10000);
716
- var y1 = parseInt((parseFloat(document.getElementById(\"mouseup\").value)-x1)*10000);
717
- var x = Math.min(x0, x1);
718
- var y = Math.min(y0, y1);
719
- var w = Math.max(x0, x1)-x;
720
- var h = Math.max(y0, y1)-y;
721
- document.getElementById(\"select_frame\").style.left = e.target.getBoundingClientRect().x + x/e.target.width*e.target.getBoundingClientRect().width + \"px\";
722
- document.getElementById(\"select_frame\").style.width = w/e.target.width*e.target.getBoundingClientRect().width + \"px\";
723
- document.getElementById(\"select_frame\").style.top = e.target.getBoundingClientRect().y + y/e.target.height*e.target.getBoundingClientRect().height + \"px\";
724
- document.getElementById(\"select_frame\").style.height = h/e.target.height*e.target.getBoundingClientRect().height + \"px\";
725
-
726
- document.getElementById(\"mouse\").getElementsByTagName(\"textarea\")[0].value = x + \", \" + y + \", \" + w + \", \" + h;
727
- var evt = document.createEvent(\"Event\");
728
- evt.initEvent(\"input\", true, false);
729
- document.getElementById(\"mouse\").getElementsByTagName(\"textarea\")[0].dispatchEvent(evt);
730
- }'>selector</a>""")
731
  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='
732
  if (!BABYLON.Engine.LastCreatedScene.activeCamera.metadata) {
733
  var evt = document.createEvent(\"Event\");
 
410
  output_switch = gr.Checkbox(label="Show depths")
411
  output_switch.input(fn=switch_rows, inputs=[output_switch], outputs=[output_frame])
412
  output_mask = gr.ImageEditor(layers=True, sources=None, type="numpy", interactive=True, transforms=(None,), eraser=gr.Eraser(), brush=gr.Brush(default_size=0, colors=['black', '#505050', '#a0a0a0', 'white']), elem_id="image_edit")
413
+ selector = gr.HTML(value="""<div id='select_frame' style='position:absolute;border:1px dashed #808080;width:0;height:0'></div>
414
+ <input type='number' id='mousedown' style='width:10em;color:auto;background-color:transparent;border:1px solid lightgray;'/>
415
+ <input type='number' id='mouseup' style='width:10em;color:auto;background-color:transparent;border:1px solid lightgray;'/>
416
+ <a href='#' id='selector' onclick='
417
+ document.body.appendChild(document.getElementById(\"select_frame\"));
418
+ document.getElementById(\"image_edit\").getElementsByTagName(\"canvas\")[0].onpointerdown = function(e) {
419
+ var x = parseInt((e.clientX-e.target.getBoundingClientRect().x)*e.target.width/e.target.getBoundingClientRect().width);
420
+ var y = parseInt((e.clientY-e.target.getBoundingClientRect().y)*e.target.height/e.target.getBoundingClientRect().height);
421
+ document.getElementById(\"mousedown\").value = x + y / 10000;
422
+
423
+ document.getElementById(\"select_frame\").style.left = 0;
424
+ document.getElementById(\"select_frame\").style.width = 0;
425
+ document.getElementById(\"select_frame\").style.top = 0;
426
+ document.getElementById(\"select_frame\").style.height = 0;
427
+ }
428
+ document.getElementById(\"image_edit\").getElementsByTagName(\"canvas\")[0].onpointerup = function(e) {
429
+ var x = parseInt((e.clientX-e.target.getBoundingClientRect().x)*e.target.width/e.target.getBoundingClientRect().width);
430
+ var y = parseInt((e.clientY-e.target.getBoundingClientRect().y)*e.target.height/e.target.getBoundingClientRect().height);
431
+ document.getElementById(\"mouseup\").value = x + y / 10000;
432
+
433
+ var x0 = parseInt(document.getElementById(\"mousedown\").value);
434
+ var x1 = parseInt(document.getElementById(\"mouseup\").value);
435
+ var y0 = parseInt((parseFloat(document.getElementById(\"mousedown\").value)-x0)*10000);
436
+ var y1 = parseInt((parseFloat(document.getElementById(\"mouseup\").value)-x1)*10000);
437
+ var x = Math.min(x0, x1);
438
+ var y = Math.min(y0, y1);
439
+ var w = Math.max(x0, x1)-x;
440
+ var h = Math.max(y0, y1)-y;
441
+ document.getElementById(\"select_frame\").style.left = e.target.getBoundingClientRect().x + x/e.target.width*e.target.getBoundingClientRect().width + \"px\";
442
+ document.getElementById(\"select_frame\").style.width = w/e.target.width*e.target.getBoundingClientRect().width + \"px\";
443
+ document.getElementById(\"select_frame\").style.top = e.target.getBoundingClientRect().y + y/e.target.height*e.target.getBoundingClientRect().height + \"px\";
444
+ document.getElementById(\"select_frame\").style.height = h/e.target.height*e.target.getBoundingClientRect().height + \"px\";
445
+
446
+ document.getElementById(\"mouse\").getElementsByTagName(\"textarea\")[0].value = x + \", \" + y + \", \" + w + \", \" + h;
447
+ var evt = document.createEvent(\"Event\");
448
+ evt.initEvent(\"input\", true, false);
449
+ document.getElementById(\"mouse\").getElementsByTagName(\"textarea\")[0].dispatchEvent(evt);
450
+ }' title='select'>⬚</a>""")
451
+ mouse = gr.Textbox(elem_id="mouse", value="""0, 0, 0, 0""")
452
+ output_mask.apply(fn=draw_mask, inputs=[mouse, output_mask], outputs=[output_mask])
453
  submit = gr.Button("Submit")
454
  with gr.Column():
455
  model_type = gr.Dropdown([("small", "vits"), ("base", "vitb"), ("large", "vitl")], type="value", value="vits", label='Model Type')
 
728
  BABYLON.Engine.LastCreatedScene.activeCamera.metadata.gizmoManager.attachToMesh(BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1]);
729
 
730
  '>reset camera</a>""")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
731
  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='
732
  if (!BABYLON.Engine.LastCreatedScene.activeCamera.metadata) {
733
  var evt = document.createEvent(\"Event\");