freealise commited on
Commit
7afa34d
β€’
1 Parent(s): ebb3c24

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -88
app.py CHANGED
@@ -451,6 +451,11 @@ with gr.Blocks(css=css) as demo:
451
  blur_in = gr.Textbox(value="", label="Kernel size", show_label=False)
452
  with gr.Accordion(label="Locations", open=False):
453
  offset = gr.HTML(value="""<input type='text' id='kbrd' onkeydown='
 
 
 
 
 
454
  event.preventDefault();
455
  if (BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].rotationQuaternion) {
456
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].rotationQuaternion = null;
@@ -458,163 +463,98 @@ with gr.Blocks(css=css) as demo:
458
  switch(event.key) {
459
  case \"w\":
460
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].position.y += 1;
 
461
  break;
462
  case \"x\":
463
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].position.y -= 1;
 
464
  break;
465
  case \"a\":
466
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].position.z -= 1;
 
467
  break;
468
  case \"d\":
469
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].position.z += 1;
 
470
  break;
471
  case \"e\":
472
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].position.x -= 1;
 
473
  break;
474
  case \"z\":
475
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].position.x += 1;
 
476
  break;
477
  case \"s\":
478
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].position.x = 0;
479
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].position.y = 0;
480
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].position.z = 0;
 
481
  break;
482
  case \"t\":
483
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].rotation.z += Math.PI/256;
 
484
  break;
485
  case \"b\":
486
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].rotation.z -= Math.PI/256;
 
487
  break;
488
  case \"f\":
489
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].rotation.y -= Math.PI/256;
 
490
  break;
491
  case \"h\":
492
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].rotation.y += Math.PI/256;
 
493
  break;
494
  case \"y\":
495
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].rotation.x -= Math.PI/256;
 
496
  break;
497
  case \"v\":
498
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].rotation.x += Math.PI/256;
 
499
  break;
500
  case \"g\":
501
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].rotation.x = 0;
502
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].rotation.y = 0;
503
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].rotation.z = 0;
 
504
  break;
505
  case \"i\":
506
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].scaling.y *= 256/255;
 
507
  break;
508
  case \",\":
509
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].scaling.y /= 256/255;
 
510
  break;
511
  case \"j\":
512
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].scaling.z /= 256/255;
 
513
  break;
514
  case \"l\":
515
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].scaling.z *= 256/255;
 
516
  break;
517
  case \"o\":
518
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].scaling.x /= 256/255;
 
519
  break;
520
  case \"m\":
521
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].scaling.x *= 256/255;
 
522
  break;
523
  case \"k\":
524
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].scaling.x = 1;
525
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].scaling.y = 1;
526
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].scaling.z = 1;
 
527
  break;
528
  default:
529
- // code block
530
- }
531
- '/><pre>
532
- ,---,---,---,---,---,---,---,---,---,---,---,---,---,-------,
533
- |1/2| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | + | ' | <- |
534
- |---'-,-'-,-'-,-'-,-'-,-'-,-'-,-'-,-'-,-'-,-'-,-'-,-'-,-----|
535
- | ->| | Q | W | E | R | T | Y | U | I | O | P | ] | ^ | |
536
- |-----',--',--',--',--',--',--',--',--',--',--',--',--'| |
537
- | Caps | A | S | D | F | G | H | J | K | L | \ | [ | * | |
538
- |----,-'-,-'-,-'-,-'-,-'-,-'-,-'-,-'-,-'-,-'-,-'-,-'---'----|
539
- | | < | Z | X | C | V | B | N | M | , | . | - | |
540
- |----'-,-',--'--,'---'---'---'---'---'---'-,-'---',--,------|
541
- | ctrl | | alt | |altgr | | ctrl |
542
- '------' '-----'--------------------------'------' '------'
543
- </pre><svg id='offset' height='256' width='288' viewBox='0 0 288 256' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' style='touch-action:none;background-color:transparent;' onpointerdown='
544
- if (!BABYLON.Engine.LastCreatedScene.activeCamera.metadata) {
545
- var evt = document.createEvent(\"Event\");
546
- evt.initEvent(\"click\", true, false);
547
- document.getElementById(\"reset_cam\").dispatchEvent(evt);
548
- }
549
- if (this.style.backgroundColor != \"#808080\") {
550
- this.style.backgroundColor = \"#808080\";
551
- this.onpointermove = function(event) {
552
- if (this.title != \"\") {
553
- x = parseInt(event.clientX - this.getBoundingClientRect().x);
554
- y = parseInt(event.clientY - this.getBoundingClientRect().y);
555
- if (x < 0) { x = 0; } else if (x > 287) { x = 287; }
556
- if (y < 0) { y = 0; } else if (y > 255) { y = 255; }
557
-
558
- if (document.getElementById(\"cr\").getAttribute(\"stroke\") == \"none\") {
559
- if (x > 255 && xold > 255) {
560
- BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].position.y = 256-y-128;
561
- document.getElementById(\"cr\").setAttribute(\"r\", (256-y)/2);
562
- } else {
563
- BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].position.z = x-128;
564
- BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].position.x = y-128;
565
- document.getElementById(\"cr\").setAttribute(\"cx\", x);
566
- document.getElementById(\"cr\").setAttribute(\"cy\", y);
567
- }
568
- } else if (document.getElementById(\"cr\").getAttribute(\"stroke\") == \"black\") {
569
- BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].rotationQuaternion = null;
570
- if (x > 255 && xold > 255) {
571
- BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].rotation.y = (y-128)/128*Math.PI;
572
- document.getElementById(\"rg\").setAttribute(\"r\", (256-y)/256*100+\"%\");
573
- } else {
574
- BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].rotation.x = (x-128)/128*Math.PI;
575
- BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].rotation.z = (y-128)/128*Math.PI;
576
- document.getElementById(\"rg\").setAttribute(\"cx\", x/256*100+\"%\");
577
- document.getElementById(\"rg\").setAttribute(\"cy\", y/256*100+\"%\");
578
- }
579
- }
580
- xold = x;
581
- yold = y;
582
- }
583
  }
584
- this.onpointerup = function(event) {
585
- this.title = \"\";
586
- }
587
- this.onpointerleave = function(event) {
588
- this.title = \"\";
589
- }
590
- this.onpointerdown = function(event) {
591
- xold = parseInt(event.clientX - event.target.getBoundingClientRect().x);
592
- yold = parseInt(event.clientY - event.target.getBoundingClientRect().y);
593
- this.title = xold+\",\"+yold;
594
- }
595
- this.onclick = function(event) {
596
- }
597
- }
598
- '>
599
- <defs>
600
- <radialGradient id='rg' cx='50%' cy='50%' r='50%'>
601
- <stop offset='0%' stop-color='white'/>
602
- <stop offset='100%' stop-color='black'/>
603
- </radialGradient>
604
- </defs>
605
- <circle cx='127' cy='127' r='64' id='cr' stroke='none' fill='url(#rg)'/>
606
- <line x1='256' y1='0' x2='256' y2='256' stroke='black' />
607
- </svg><br/><label for='mode'>Mode </label><select id='mode' onchange='
608
- try {
609
- if (this.selectedIndex == 0) {
610
- document.getElementById(\"cr\").setAttribute(\"stroke\", \"none\");
611
- } else if (this.selectedIndex == 1) {
612
- document.getElementById(\"cr\").setAttribute(\"stroke\", \"black\");
613
- } else if (this.selectedIndex == 2) {
614
- document.getElementById(\"cr\").setAttribute(\"stroke\", \"white\");
615
- }
616
- } catch(e) {alert(e);}
617
- ' onload=''><option>Move</option><option>Rotate</option><option>Scale</option></select>""")
618
  selected = gr.Number(elem_id="fnum", value=0, minimum=0, maximum=256, interactive=False)
619
  output_frame.select(fn=select_frame, inputs=None, outputs=[output_depth, selected], show_progress='hidden')
620
  output_depth.select(fn=select_frame, inputs=None, outputs=[output_frame, selected], show_progress='hidden')
 
451
  blur_in = gr.Textbox(value="", label="Kernel size", show_label=False)
452
  with gr.Accordion(label="Locations", open=False):
453
  offset = gr.HTML(value="""<input type='text' id='kbrd' onkeydown='
454
+ if (!BABYLON.Engine.LastCreatedScene.activeCamera.metadata) {
455
+ var evt = document.createEvent(\"Event\");
456
+ evt.initEvent(\"click\", true, false);
457
+ document.getElementById(\"reset_cam\").dispatchEvent(evt);
458
+ }
459
  event.preventDefault();
460
  if (BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].rotationQuaternion) {
461
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].rotationQuaternion = null;
 
463
  switch(event.key) {
464
  case \"w\":
465
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].position.y += 1;
466
+ this.value = \"w | x\";
467
  break;
468
  case \"x\":
469
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].position.y -= 1;
470
+ this.value = \"w | x\";
471
  break;
472
  case \"a\":
473
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].position.z -= 1;
474
+ this.value = \"a | d\";
475
  break;
476
  case \"d\":
477
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].position.z += 1;
478
+ this.value = \"a | d\";
479
  break;
480
  case \"e\":
481
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].position.x -= 1;
482
+ this.value = \"z | e\";
483
  break;
484
  case \"z\":
485
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].position.x += 1;
486
+ this.value = \"z | e\";
487
  break;
488
  case \"s\":
489
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].position.x = 0;
490
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].position.y = 0;
491
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].position.z = 0;
492
+ this.value = \"\";
493
  break;
494
  case \"t\":
495
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].rotation.z += Math.PI/256;
496
+ this.value = \"t πŸ”ƒ b\";
497
  break;
498
  case \"b\":
499
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].rotation.z -= Math.PI/256;
500
+ this.value = \"t πŸ”ƒ b\";
501
  break;
502
  case \"f\":
503
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].rotation.y -= Math.PI/256;
504
+ this.value = \"f πŸ” h\";
505
  break;
506
  case \"h\":
507
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].rotation.y += Math.PI/256;
508
+ this.value = \"f πŸ” h\";
509
  break;
510
  case \"y\":
511
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].rotation.x -= Math.PI/256;
512
+ this.value = \"v πŸ”„ y\";
513
  break;
514
  case \"v\":
515
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].rotation.x += Math.PI/256;
516
+ this.value = \"v πŸ”„ y\";
517
  break;
518
  case \"g\":
519
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].rotation.x = 0;
520
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].rotation.y = 0;
521
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].rotation.z = 0;
522
+ this.value = \"\";
523
  break;
524
  case \"i\":
525
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].scaling.y *= 256/255;
526
+ this.value = \"i | ,\";
527
  break;
528
  case \",\":
529
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].scaling.y /= 256/255;
530
+ this.value = \"i | ,\";
531
  break;
532
  case \"j\":
533
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].scaling.z /= 256/255;
534
+ this.value = \"j | l\";
535
  break;
536
  case \"l\":
537
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].scaling.z *= 256/255;
538
+ this.value = \"j | l\";
539
  break;
540
  case \"o\":
541
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].scaling.x /= 256/255;
542
+ this.value = \"m | o\";
543
  break;
544
  case \"m\":
545
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].scaling.x *= 256/255;
546
+ this.value = \"m | o\";
547
  break;
548
  case \"k\":
549
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].scaling.x = 1;
550
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].scaling.y = 1;
551
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].scaling.z = 1;
552
+ this.value = \"\";
553
  break;
554
  default:
555
+ this.value = \"\";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
556
  }
557
+ '/>""")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
558
  selected = gr.Number(elem_id="fnum", value=0, minimum=0, maximum=256, interactive=False)
559
  output_frame.select(fn=select_frame, inputs=None, outputs=[output_depth, selected], show_progress='hidden')
560
  output_depth.select(fn=select_frame, inputs=None, outputs=[output_frame, selected], show_progress='hidden')