freealise commited on
Commit
de2190d
1 Parent(s): 4caec38

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -32
app.py CHANGED
@@ -850,29 +850,29 @@ with gr.Blocks(css=css, js=js) as demo:
850
  input_video = gr.Video(label="Input Video", format="mp4")
851
  input_url.input(fn=loadfile, inputs=[input_url], outputs=[input_video])
852
  submit = gr.Button("Submit")
853
- output_frame = gr.Gallery(label="Frames", preview=True, columns=8192, interactive=False)
854
  with gr.Group():
855
- with gr.Row():
856
- output_switch = gr.Checkbox(label="Show depths")
857
- selected = gr.Number(label="Selected frame", show_label=False, elem_id="fnum", value=0, minimum=0, maximum=256, interactive=False)
858
- with gr.Accordion(label="Depths", open=False):
859
- output_depth = gr.Files(label="Depth files", interactive=False)
860
- output_switch.input(fn=switch_rows, inputs=[output_switch], outputs=[output_frame])
861
- output_mask = gr.ImageEditor(layers=False, sources=('upload', 'clipboard'), show_download_button=True, type="numpy", interactive=True, transforms=(None,), eraser=gr.Eraser(), brush=gr.Brush(default_size=0, colors=['black', '#505050', '#a0a0a0', 'white']), elem_id="image_edit")
862
- with gr.Row():
863
  reset = gr.Button("Reset", size='sm')
864
- with gr.Accordion(label="Border", open=False):
865
- boffset = gr.Slider(label="Offset", value=1, maximum=256, minimum=0, step=1)
866
- bsize = gr.Slider(label="Size", value=32, maximum=256, minimum=0, step=1)
867
- mouse = gr.Textbox(label="Mouse x,y", elem_id="mouse", value="""[]""", interactive=False)
868
  mouse.input(fn=draw_mask, show_progress="minimal", inputs=[boffset, bsize, mouse, output_mask], outputs=[output_mask])
869
  reset.click(fn=reset_mask, inputs=[output_mask], outputs=[output_mask])
870
 
871
  with gr.Column():
872
- model_type = gr.Dropdown([("small", "vits"), ("base", "vitb"), ("large", "vitl"), ("giant", "vitg")], type="value", value="vits", label='Model Type')
873
- processed_video = gr.Video(label="Output Video", format="mp4", interactive=False)
874
- processed_zip = gr.File(label="Output Archive", interactive=False)
875
- result = gr.Model3D(label="3D Mesh", clear_color=[0.5, 0.5, 0.5, 0.0], camera_position=[0, 90, 0], zoom_speed=2.0, pan_speed=2.0, interactive=True, elem_id="model3D") #, display_mode="point_cloud"
 
876
  chart_c = gr.HTML(elem_id="chart_c", value="""<div id='chart' onpointermove='window.drawLine(event.clientX, event.clientY);' onpointerdown='window.pointerDown(event.clientX, event.clientY);' onpointerup='window.pointerUp();' onpointerleave='window.pointerUp();' onpointercancel='window.pointerUp();' onclick='window.resetLine();'></div>
877
  <style>
878
  body {
@@ -924,24 +924,24 @@ with gr.Blocks(css=css, js=js) as demo:
924
  ' oninput='
925
  this.parentNode.childNodes[2].innerText = this.value;
926
  ' onchange='this.click();'/><span>1</span>""")
927
- with gr.Group():
928
- with gr.Accordion(label="Blur levels", open=False):
929
- blur_in = gr.Textbox(elem_id="blur_in", label="Kernel size", show_label=False, interactive=False, value=blurin)
930
- with gr.Accordion(label="Locations", open=False):
931
- output_frame.select(fn=select_frame, inputs=[output_mask], outputs=[output_mask, selected])
932
- example_coords = """[
933
  {"lat": 50.07379596793083, "lng": 14.437146122950555, "heading": 152.70303, "pitch": 2.607833999999997},
934
  {"lat": 50.073799567020004, "lng": 14.437146774240507, "heading": 151.12973, "pitch": 2.8672300000000064},
935
  {"lat": 50.07377647505558, "lng": 14.437161000659017, "heading": 151.41025, "pitch": 3.4802200000000028},
936
  {"lat": 50.07379496839027, "lng": 14.437148958238538, "heading": 151.93391, "pitch": 2.843050000000005},
937
  {"lat": 50.073823157821664, "lng": 14.437124189538856, "heading": 152.95769, "pitch": 4.233024999999998}
938
  ]"""
939
- coords = gr.Textbox(elem_id="coords", value=example_coords, label="Coordinates", interactive=False)
940
- mesh_order = gr.Textbox(elem_id="order", value="", label="Order", interactive=False)
941
- load_all = gr.Checkbox(label="Load all")
942
 
943
- with gr.Row():
944
- 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='
945
  if (!BABYLON.Engine.LastCreatedScene.activeCamera.metadata) {
946
  var evt = document.createEvent(\"Event\");
947
  evt.initEvent(\"click\", true, false);
@@ -952,7 +952,7 @@ with gr.Blocks(css=css, js=js) as demo:
952
 
953
  document.getElementById(\"model3D\").getElementsByTagName(\"canvas\")[0].style.filter = \"blur(\" + BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].material.pointSize/2.0*Math.sqrt(2.0) + \"px)\";
954
  '/><span>0.8</span>""")
955
- camera = gr.HTML(value="""<a href='#' id='reset_cam' style='color:white' onclick='
956
  if (!BABYLON.Engine.LastCreatedScene.activeCamera.metadata) {
957
  BABYLON.Engine.LastCreatedScene.activeCamera.metadata = {
958
  screenshot: true,
@@ -969,8 +969,7 @@ with gr.Blocks(css=css, js=js) as demo:
969
  document.getElementById(\"model3D\").getElementsByTagName(\"canvas\")[0].oncontextmenu = function(e){e.preventDefault();}
970
  document.getElementById(\"model3D\").getElementsByTagName(\"canvas\")[0].ondrag = function(e){e.preventDefault();}
971
  '>Reset camera</a>""")
972
-
973
- contrast = gr.HTML(value="""<label for='contrast'>Contrast</label><input id='contrast' type='range' style='width:256px;height:1em;' value='1.0' min='0' max='2' step='0.001' oninput='
974
  if (!BABYLON.Engine.LastCreatedScene.activeCamera.metadata) {
975
  var evt = document.createEvent(\"Event\");
976
  evt.initEvent(\"click\", true, false);
@@ -979,7 +978,7 @@ with gr.Blocks(css=css, js=js) as demo:
979
  BABYLON.Engine.LastCreatedScene.activeCamera.metadata.pipeline.imageProcessing.contrast = this.value;
980
  this.parentNode.childNodes[2].innerText = BABYLON.Engine.LastCreatedScene.activeCamera.metadata.pipeline.imageProcessing.contrast;
981
  '/><span>1.0</span>""")
982
- exposure = gr.HTML(value="""<label for='exposure'>Exposure</label><input id='exposure' type='range' style='width:256px;height:1em;' value='1.0' min='0' max='2' step='0.001' oninput='
983
  if (!BABYLON.Engine.LastCreatedScene.activeCamera.metadata) {
984
  var evt = document.createEvent(\"Event\");
985
  evt.initEvent(\"click\", true, false);
 
850
  input_video = gr.Video(label="Input Video", format="mp4")
851
  input_url.input(fn=loadfile, inputs=[input_url], outputs=[input_video])
852
  submit = gr.Button("Submit")
 
853
  with gr.Group():
854
+ output_frame = gr.Gallery(label="Frames", preview=True, columns=8192, interactive=False)
855
+ output_switch = gr.Checkbox(label="Show depths")
856
+ output_switch.input(fn=switch_rows, inputs=[output_switch], outputs=[output_frame])
857
+ selected = gr.Number(label="Selected frame", visible=False, elem_id="fnum", value=0, minimum=0, maximum=256, interactive=False)
858
+ with gr.Accordion(label="Depths", open=False):
859
+ output_depth = gr.Files(label="Depth files", interactive=False)
860
+ with gr.Group():
861
+ output_mask = gr.ImageEditor(layers=False, sources=('upload', 'clipboard'), show_download_button=True, type="numpy", interactive=True, transforms=(None,), eraser=gr.Eraser(), brush=gr.Brush(default_size=0, colors=['black', '#505050', '#a0a0a0', 'white']), elem_id="image_edit")
862
  reset = gr.Button("Reset", size='sm')
863
+ with gr.Accordion(label="Border", open=False):
864
+ boffset = gr.Slider(label="Offset", value=1, maximum=256, minimum=0, step=1)
865
+ bsize = gr.Slider(label="Size", value=32, maximum=256, minimum=0, step=1)
866
+ mouse = gr.Textbox(label="Mouse x,y", elem_id="mouse", value="""[]""", interactive=False)
867
  mouse.input(fn=draw_mask, show_progress="minimal", inputs=[boffset, bsize, mouse, output_mask], outputs=[output_mask])
868
  reset.click(fn=reset_mask, inputs=[output_mask], outputs=[output_mask])
869
 
870
  with gr.Column():
871
+ model_type = gr.Dropdown([("small", "vits"), ("base", "vitb"), ("large", "vitl"), ("giant", "vitg")], type="value", value="vits", label='Model Type')
872
+ processed_video = gr.Video(label="Output Video", format="mp4", interactive=False)
873
+ processed_zip = gr.File(label="Output Archive", interactive=False)
874
+ result = gr.Model3D(label="3D Mesh", clear_color=[0.5, 0.5, 0.5, 0.0], camera_position=[0, 90, 0], zoom_speed=2.0, pan_speed=2.0, interactive=False, elem_id="model3D")
875
+ with gr.Tab("Blur"):
876
  chart_c = gr.HTML(elem_id="chart_c", value="""<div id='chart' onpointermove='window.drawLine(event.clientX, event.clientY);' onpointerdown='window.pointerDown(event.clientX, event.clientY);' onpointerup='window.pointerUp();' onpointerleave='window.pointerUp();' onpointercancel='window.pointerUp();' onclick='window.resetLine();'></div>
877
  <style>
878
  body {
 
924
  ' oninput='
925
  this.parentNode.childNodes[2].innerText = this.value;
926
  ' onchange='this.click();'/><span>1</span>""")
927
+ with gr.Accordion(label="Blur levels", open=False):
928
+ blur_in = gr.Textbox(elem_id="blur_in", label="Kernel size", show_label=False, interactive=False, value=blurin)
929
+ with gr.Group():
930
+ with gr.Accordion(label="Locations", open=False):
931
+ output_frame.select(fn=select_frame, inputs=[output_mask], outputs=[output_mask, selected])
932
+ example_coords = """[
933
  {"lat": 50.07379596793083, "lng": 14.437146122950555, "heading": 152.70303, "pitch": 2.607833999999997},
934
  {"lat": 50.073799567020004, "lng": 14.437146774240507, "heading": 151.12973, "pitch": 2.8672300000000064},
935
  {"lat": 50.07377647505558, "lng": 14.437161000659017, "heading": 151.41025, "pitch": 3.4802200000000028},
936
  {"lat": 50.07379496839027, "lng": 14.437148958238538, "heading": 151.93391, "pitch": 2.843050000000005},
937
  {"lat": 50.073823157821664, "lng": 14.437124189538856, "heading": 152.95769, "pitch": 4.233024999999998}
938
  ]"""
939
+ coords = gr.Textbox(elem_id="coords", value=example_coords, label="Coordinates", interactive=False)
940
+ mesh_order = gr.Textbox(elem_id="order", value="", label="Order", interactive=False)
941
+ load_all = gr.Checkbox(label="Load all")
942
 
943
+ with gr.Group():
944
+ 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='
945
  if (!BABYLON.Engine.LastCreatedScene.activeCamera.metadata) {
946
  var evt = document.createEvent(\"Event\");
947
  evt.initEvent(\"click\", true, false);
 
952
 
953
  document.getElementById(\"model3D\").getElementsByTagName(\"canvas\")[0].style.filter = \"blur(\" + BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].material.pointSize/2.0*Math.sqrt(2.0) + \"px)\";
954
  '/><span>0.8</span>""")
955
+ camera = gr.HTML(value="""<a href='#' id='reset_cam' style='color:white' onclick='
956
  if (!BABYLON.Engine.LastCreatedScene.activeCamera.metadata) {
957
  BABYLON.Engine.LastCreatedScene.activeCamera.metadata = {
958
  screenshot: true,
 
969
  document.getElementById(\"model3D\").getElementsByTagName(\"canvas\")[0].oncontextmenu = function(e){e.preventDefault();}
970
  document.getElementById(\"model3D\").getElementsByTagName(\"canvas\")[0].ondrag = function(e){e.preventDefault();}
971
  '>Reset camera</a>""")
972
+ contrast = gr.HTML(value="""<label for='contrast'>Contrast</label><input id='contrast' type='range' style='width:256px;height:1em;' value='1.0' min='0' max='2' step='0.001' oninput='
 
973
  if (!BABYLON.Engine.LastCreatedScene.activeCamera.metadata) {
974
  var evt = document.createEvent(\"Event\");
975
  evt.initEvent(\"click\", true, false);
 
978
  BABYLON.Engine.LastCreatedScene.activeCamera.metadata.pipeline.imageProcessing.contrast = this.value;
979
  this.parentNode.childNodes[2].innerText = BABYLON.Engine.LastCreatedScene.activeCamera.metadata.pipeline.imageProcessing.contrast;
980
  '/><span>1.0</span>""")
981
+ exposure = gr.HTML(value="""<label for='exposure'>Exposure</label><input id='exposure' type='range' style='width:256px;height:1em;' value='1.0' min='0' max='2' step='0.001' oninput='
982
  if (!BABYLON.Engine.LastCreatedScene.activeCamera.metadata) {
983
  var evt = document.createEvent(\"Event\");
984
  evt.initEvent(\"click\", true, false);