freealise commited on
Commit
2ea14e3
1 Parent(s): 6c52b98

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +60 -61
app.py CHANGED
@@ -357,67 +357,7 @@ with gr.Blocks(css=css) as demo:
357
  model_type = gr.Dropdown([("small", "vits"), ("base", "vitb"), ("large", "vitl")], type="value", value="vits", label='Model Type')
358
  processed_video = gr.Video(label="Output Video", format="mp4")
359
  processed_zip = gr.File(label="Output Archive")
360
- result = gr.Model3D(label="3D Mesh", clear_color=[0.5, 0.5, 0.5, 0.0], camera_position=[0, 90, 0], interactive=True, elem_id="model3D")
361
- with gr.Accordion(label="Locations", open=False):
362
- selected = gr.Number(elem_id="fnum", value=0, minimum=0, maximum=256, interactive=False)
363
- output_frame.select(fn=select_frame, inputs=None, outputs=[output_depth, selected], show_progress='hidden')
364
- output_depth.select(fn=select_frame, inputs=None, outputs=[output_frame, selected], show_progress='hidden')
365
- example_coords = '50.07379596793083,14.437146122950555 50.073799567020004,14.437146774240507 50.07377647505558,14.437161000659017 50.07379496839027,14.437148958238538 50.073823157821664,14.437124189538856'
366
- coords = gr.Textbox(elem_id="coords", value=example_coords, label="Precise coordinates", show_label=False)
367
- offset = gr.HTML(value="""<svg id='offset' height='256' width='256' viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' style='touch-action:none;background-color:transparent;' onpointerdown='
368
- if (!BABYLON.Engine.LastCreatedScene.activeCamera.metadata) {
369
- var evt = document.createEvent(\"Event\");
370
- evt.initEvent(\"click\", true, false);
371
- document.getElementById(\"reset_cam\").dispatchEvent(evt);
372
- }
373
- if (this.style.backgroundColor != \"#808080\") {
374
- this.style.backgroundColor = \"#808080\";
375
- this.onpointermove = function(event) {
376
- if (this.title != \"\") {
377
- try{
378
- x = parseInt(event.clientX - this.getBoundingClientRect().x);
379
- y = parseInt(event.clientY - this.getBoundingClientRect().y);
380
- if (x < 0) { x = 0; } else if (x > 255) { x = 255; }
381
- if (y < 0) { y = 0; } else if (y > 255) { y = 255; }
382
-
383
- BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].position.x = x-128;
384
- BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].position.y = y-128;
385
-
386
- xold = x;
387
- yold = y;
388
- document.getElementById(\"cr\").setAttribute(\"cx\", x);
389
- document.getElementById(\"cr\").setAttribute(\"cy\", y);
390
- }catch(e){alert(e);}
391
- }
392
- }
393
- this.onpointerup = function(event) {
394
- this.title = \"\";
395
- }
396
- this.onpointerleave = function(event) {
397
- this.title = \"\";
398
- }
399
- this.onpointerdown = function(event) {
400
- xold = parseInt(event.clientX - event.target.getBoundingClientRect().x);
401
- yold = parseInt(event.clientY - event.target.getBoundingClientRect().y);
402
- this.title = xold+\",\"+yold;
403
- }
404
- this.onclick = function(event) {
405
- alert(BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].rotation);
406
- try{
407
- BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].rotation.y = parseInt(event.clientX - this.getBoundingClientRect().x-128)/128*Math.PI;
408
- }catch(e){alert(e);}
409
- }
410
- }
411
- '>
412
- <defs>
413
- <linearGradient id='lg' x1='0%' x2='100%' y1='0%' y2='0%'>
414
- <stop offset='0%' stop-color='white'/>
415
- <stop offset='100%' stop-color='black'/>
416
- </linearGradient>
417
- </defs>
418
- <circle cx="127" cy="127" r="32" id='cr' stroke='none' fill='url(#lg)'/>
419
- </svg>""")
420
-
421
  svg_in = gr.HTML(value="""<svg id='svg_in' height='32' width='256' viewBox='0 0 256 32' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' style='touch-action:none;background-color:#808080;' onpointerdown='
422
  try{
423
  if (document.getElementById(\"pl\").getAttribute(\"points\").length < 256) {
@@ -507,6 +447,65 @@ with gr.Blocks(css=css) as demo:
507
  '/><span>1</span>""")
508
  with gr.Accordion(label="Blur levels", open=False):
509
  blur_in = gr.Textbox(value="", label="Kernel size", show_label=False)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
510
 
511
  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='
512
  if (!BABYLON.Engine.LastCreatedScene.activeCamera.metadata) {
 
357
  model_type = gr.Dropdown([("small", "vits"), ("base", "vitb"), ("large", "vitl")], type="value", value="vits", label='Model Type')
358
  processed_video = gr.Video(label="Output Video", format="mp4")
359
  processed_zip = gr.File(label="Output Archive")
360
+ result = gr.Model3D(label="3D Mesh", clear_color=[0.5, 0.5, 0.5, 0.0], camera_position=[0, 90, 0], interactive=True, elem_id="model3D")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
361
  svg_in = gr.HTML(value="""<svg id='svg_in' height='32' width='256' viewBox='0 0 256 32' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' style='touch-action:none;background-color:#808080;' onpointerdown='
362
  try{
363
  if (document.getElementById(\"pl\").getAttribute(\"points\").length < 256) {
 
447
  '/><span>1</span>""")
448
  with gr.Accordion(label="Blur levels", open=False):
449
  blur_in = gr.Textbox(value="", label="Kernel size", show_label=False)
450
+ with gr.Accordion(label="Locations", open=False):
451
+ selected = gr.Number(elem_id="fnum", value=0, minimum=0, maximum=256, interactive=False)
452
+ output_frame.select(fn=select_frame, inputs=None, outputs=[output_depth, selected], show_progress='hidden')
453
+ output_depth.select(fn=select_frame, inputs=None, outputs=[output_frame, selected], show_progress='hidden')
454
+ example_coords = '50.07379596793083,14.437146122950555 50.073799567020004,14.437146774240507 50.07377647505558,14.437161000659017 50.07379496839027,14.437148958238538 50.073823157821664,14.437124189538856'
455
+ coords = gr.Textbox(elem_id="coords", value=example_coords, label="Precise coordinates", show_label=False)
456
+ offset = gr.HTML(value="""<svg id='offset' height='256' width='256' viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' style='touch-action:none;background-color:transparent;' onpointerdown='
457
+ if (!BABYLON.Engine.LastCreatedScene.activeCamera.metadata) {
458
+ var evt = document.createEvent(\"Event\");
459
+ evt.initEvent(\"click\", true, false);
460
+ document.getElementById(\"reset_cam\").dispatchEvent(evt);
461
+ }
462
+ if (this.style.backgroundColor != \"#808080\") {
463
+ this.style.backgroundColor = \"#808080\";
464
+ this.onpointermove = function(event) {
465
+ if (this.title != \"\") {
466
+ try{
467
+ x = parseInt(event.clientX - this.getBoundingClientRect().x);
468
+ y = parseInt(event.clientY - this.getBoundingClientRect().y);
469
+ if (x < 0) { x = 0; } else if (x > 255) { x = 255; }
470
+ if (y < 0) { y = 0; } else if (y > 255) { y = 255; }
471
+
472
+ BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].position.x = x-128;
473
+ BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].position.y = y-128;
474
+
475
+ xold = x;
476
+ yold = y;
477
+ document.getElementById(\"cr\").setAttribute(\"cx\", x);
478
+ document.getElementById(\"cr\").setAttribute(\"cy\", y);
479
+ }catch(e){alert(e);}
480
+ }
481
+ }
482
+ this.onpointerup = function(event) {
483
+ this.title = \"\";
484
+ }
485
+ this.onpointerleave = function(event) {
486
+ this.title = \"\";
487
+ }
488
+ this.onpointerdown = function(event) {
489
+ xold = parseInt(event.clientX - event.target.getBoundingClientRect().x);
490
+ yold = parseInt(event.clientY - event.target.getBoundingClientRect().y);
491
+ this.title = xold+\",\"+yold;
492
+ }
493
+ this.onclick = function(event) {
494
+ alert(BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].rotation);
495
+ try{
496
+ BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].rotation.y = parseInt(event.clientX - this.getBoundingClientRect().x-128)/128*Math.PI;
497
+ }catch(e){alert(e);}
498
+ }
499
+ }
500
+ '>
501
+ <defs>
502
+ <linearGradient id='lg' x1='0%' x2='100%' y1='0%' y2='0%'>
503
+ <stop offset='0%' stop-color='white'/>
504
+ <stop offset='100%' stop-color='black'/>
505
+ </linearGradient>
506
+ </defs>
507
+ <circle cx="127" cy="127" r="32" id='cr' stroke='none' fill='url(#lg)'/>
508
+ </svg>""")
509
 
510
  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='
511
  if (!BABYLON.Engine.LastCreatedScene.activeCamera.metadata) {