Update app.py
Browse files
app.py
CHANGED
@@ -557,32 +557,6 @@ def draw_mask(o, b, v, d, evt: gr.EventData):
|
|
557 |
return gr.ImageEditor(value=d)
|
558 |
|
559 |
|
560 |
-
def findNormals(format):
|
561 |
-
global depths
|
562 |
-
d_im = cv2.cvtColor(cv2.imread(depths[frame_selected]).astype(np.uint8), cv2.COLOR_BGR2GRAY)
|
563 |
-
zy, zx = np.gradient(d_im)
|
564 |
-
# You may also consider using Sobel to get a joint Gaussian smoothing and differentation
|
565 |
-
# to reduce noise
|
566 |
-
#zx = cv2.Sobel(d_im, cv2.CV_64F, 1, 0, ksize=5)
|
567 |
-
#zy = cv2.Sobel(d_im, cv2.CV_64F, 0, 1, ksize=5)
|
568 |
-
|
569 |
-
if format == "opengl":
|
570 |
-
zy = -zy
|
571 |
-
|
572 |
-
normal = np.dstack((np.ones_like(d_im), -zy, -zx))
|
573 |
-
n = np.linalg.norm(normal, axis=2)
|
574 |
-
normal[:, :, 0] /= n
|
575 |
-
normal[:, :, 1] /= n
|
576 |
-
normal[:, :, 2] /= n
|
577 |
-
|
578 |
-
# offset and rescale values to be in 0-255
|
579 |
-
normal += 1
|
580 |
-
normal /= 2
|
581 |
-
normal *= 255
|
582 |
-
|
583 |
-
return (normal[:, :, ::-1]).astype(np.uint8)
|
584 |
-
|
585 |
-
|
586 |
load_model="""
|
587 |
async(c, o, p, d, n, m)=>{
|
588 |
var intv = setInterval(function(){
|
@@ -891,11 +865,6 @@ with gr.Blocks(css=css, js=js) as demo:
|
|
891 |
mouse.input(fn=draw_mask, show_progress="minimal", inputs=[boffset, bsize, mouse, output_mask], outputs=[output_mask])
|
892 |
reset.click(fn=reset_mask, inputs=[output_mask], outputs=[output_mask])
|
893 |
|
894 |
-
normals_out = gr.Image(label="Normal map", interactive=False)
|
895 |
-
format_normals = gr.Radio(choices=["directx", "opengl"])
|
896 |
-
find_normals = gr.Button("Find normals")
|
897 |
-
find_normals.click(fn=findNormals, inputs=[format_normals], outputs=[normals_out])
|
898 |
-
|
899 |
with gr.Column():
|
900 |
model_type = gr.Dropdown([("small", "vits"), ("base", "vitb"), ("large", "vitl"), ("giant", "vitg")], type="value", value="vits", label='Model Type')
|
901 |
processed_video = gr.Video(label="Output Video", format="mp4", interactive=False)
|
|
|
557 |
return gr.ImageEditor(value=d)
|
558 |
|
559 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
560 |
load_model="""
|
561 |
async(c, o, p, d, n, m)=>{
|
562 |
var intv = setInterval(function(){
|
|
|
865 |
mouse.input(fn=draw_mask, show_progress="minimal", inputs=[boffset, bsize, mouse, output_mask], outputs=[output_mask])
|
866 |
reset.click(fn=reset_mask, inputs=[output_mask], outputs=[output_mask])
|
867 |
|
|
|
|
|
|
|
|
|
|
|
868 |
with gr.Column():
|
869 |
model_type = gr.Dropdown([("small", "vits"), ("base", "vitb"), ("large", "vitl"), ("giant", "vitg")], type="value", value="vits", label='Model Type')
|
870 |
processed_video = gr.Video(label="Output Video", format="mp4", interactive=False)
|