freealise commited on
Commit
34438a2
1 Parent(s): 2b4bae9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -9
app.py CHANGED
@@ -565,16 +565,9 @@ with gr.Blocks(css=css, js=js) as demo:
565
  output_switch = gr.Checkbox(label="Show depths")
566
  output_switch.input(fn=switch_rows, inputs=[output_switch], outputs=[output_frame])
567
  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")
568
- depth_file = gr.File(label="Edited depth")
569
- with gr.Accordion(label="Edge", open=False):
570
- levels = gr.Slider(label="Color levels", value=16, maximum=32, minimum=2, step=1)
571
- tolerance = gr.Slider(label="Tolerance", value=1, maximum=7, minimum=0, step=1)
572
- bsize = gr.Slider(label="Border size", value=15, maximum=256, minimum=1, step=2)
573
- mouse = gr.Textbox(elem_id="mouse", value="""[]""", interactive=False)
574
- mouse.input(fn=draw_mask, show_progress="minimal", inputs=[levels, tolerance, mouse, output_mask], outputs=[output_mask])
575
- output_mask.apply(fn=apply_mask, inputs=[output_mask, bsize], outputs=[output_mask, depth_file])
576
  selector = gr.HTML(value="""
577
- <a href='#' id='selector' onclick='this.style.fontWeight=\"bold\";
 
578
  document.getElementById(\"image_edit\").getElementsByTagName(\"canvas\")[0].oncontextmenu = function(e){e.preventDefault();}
579
  document.getElementById(\"image_edit\").getElementsByTagName(\"canvas\")[0].ondrag = function(e){e.preventDefault();}
580
 
@@ -600,11 +593,24 @@ with gr.Blocks(css=css, js=js) as demo:
600
 
601
  document.getElementById(\"mouse\").getElementsByTagName(\"textarea\")[0].style.borderColor = \"#ffffff\";
602
 
 
 
 
 
 
603
  }' title='Select point' style='text-decoration:none;color:white;'>⊹ Select point</a> <a href='#' id='clear_select' onclick='
604
 
605
  document.getElementById(\"mouse\").getElementsByTagName(\"textarea\")[0].value = \"[]\";
606
 
607
  ' title='Clear selection' style='text-decoration:none;color:white;'>✕ Clear selection</a>""")
 
 
 
 
 
 
 
 
608
  submit = gr.Button("Submit")
609
  with gr.Column():
610
  model_type = gr.Dropdown([("small", "vits"), ("base", "vitb"), ("large", "vitl")], type="value", value="vits", label='Model Type')
 
565
  output_switch = gr.Checkbox(label="Show depths")
566
  output_switch.input(fn=switch_rows, inputs=[output_switch], outputs=[output_frame])
567
  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")
 
 
 
 
 
 
 
 
568
  selector = gr.HTML(value="""
569
+ <a href='#' id='selector' onclick='if (this.style.fontWeight!=\"bold\") {
570
+ this.style.fontWeight=\"bold\";
571
  document.getElementById(\"image_edit\").getElementsByTagName(\"canvas\")[0].oncontextmenu = function(e){e.preventDefault();}
572
  document.getElementById(\"image_edit\").getElementsByTagName(\"canvas\")[0].ondrag = function(e){e.preventDefault();}
573
 
 
593
 
594
  document.getElementById(\"mouse\").getElementsByTagName(\"textarea\")[0].style.borderColor = \"#ffffff\";
595
 
596
+ }
597
+ } else {
598
+ this.style.fontWeight=\"normal\";
599
+ document.getElementById(\"image_edit\").getElementsByTagName(\"canvas\")[0].onclick = null;
600
+
601
  }' title='Select point' style='text-decoration:none;color:white;'>⊹ Select point</a> <a href='#' id='clear_select' onclick='
602
 
603
  document.getElementById(\"mouse\").getElementsByTagName(\"textarea\")[0].value = \"[]\";
604
 
605
  ' title='Clear selection' style='text-decoration:none;color:white;'>✕ Clear selection</a>""")
606
+ depth_file = gr.File(label="Edited depth")
607
+ with gr.Accordion(label="Edge", open=False):
608
+ levels = gr.Slider(label="Color levels", value=16, maximum=32, minimum=2, step=1)
609
+ tolerance = gr.Slider(label="Tolerance", value=1, maximum=7, minimum=0, step=1)
610
+ bsize = gr.Slider(label="Border size", value=15, maximum=256, minimum=1, step=2)
611
+ mouse = gr.Textbox(elem_id="mouse", value="""[]""", interactive=False)
612
+ mouse.input(fn=draw_mask, show_progress="minimal", inputs=[levels, tolerance, mouse, output_mask], outputs=[output_mask])
613
+ output_mask.apply(fn=apply_mask, inputs=[output_mask, bsize], outputs=[output_mask, depth_file])
614
  submit = gr.Button("Submit")
615
  with gr.Column():
616
  model_type = gr.Dropdown([("small", "vits"), ("base", "vitb"), ("large", "vitl")], type="value", value="vits", label='Model Type')