Spaces:
Starting
Starting
Update app.py
Browse files
app.py
CHANGED
@@ -574,22 +574,6 @@ def draw_mask(l, t, v, d, evt: gr.EventData):
|
|
574 |
return gr.ImageEditor(value=d)
|
575 |
|
576 |
|
577 |
-
def findNormals():
|
578 |
-
global depths
|
579 |
-
depth = cv2.imread(depths[frame_selected]).astype(np.float32)
|
580 |
-
normals = np.zeros((depth.shape[0], depth.shape[1], 3), dtype=np.float32)
|
581 |
-
|
582 |
-
for x in range(1, depth.shape[0]-1):
|
583 |
-
for y in range(1, depth.shape[1]-1):
|
584 |
-
dzdx = ((depth[x + 1, y] - depth[x - 1, y]) / 2.0).astype(np.float32)
|
585 |
-
dzdy = ((depth[x, y + 1] - depth[x, y - 1]) / 2.0).astype(np.float32)
|
586 |
-
|
587 |
-
d = np.array([dzdx, dzdy, np.float32(1.0)], dtype=np.float32)
|
588 |
-
normals[x, y] = d / np.linalg.norm(d)
|
589 |
-
|
590 |
-
return (normals * 255 + 127).astype(np.uint8)
|
591 |
-
|
592 |
-
|
593 |
load_model="""
|
594 |
async(c, o, b, p, d, n, m)=>{
|
595 |
var intv = setInterval(function(){
|
@@ -822,9 +806,7 @@ with gr.Blocks(css=css, js=js) as demo:
|
|
822 |
mouse.input(fn=draw_mask, show_progress="minimal", inputs=[levels, tolerance, mouse, output_mask], outputs=[output_mask])
|
823 |
apply.click(fn=apply_mask, inputs=[output_mask, bsize], outputs=[output_mask, output_depth, output_frame])
|
824 |
reset.click(fn=reset_mask, inputs=None, outputs=[output_mask, output_depth])
|
825 |
-
|
826 |
-
find_normals = gr.Button("Find normals")
|
827 |
-
find_normals.click(fn=findNormals, inputs=None, outputs=[normals_out])
|
828 |
with gr.Column():
|
829 |
model_type = gr.Dropdown([("small", "vits"), ("base", "vitb"), ("large", "vitl")], type="value", value="vits", label='Model Type')
|
830 |
processed_video = gr.Video(label="Output Video", format="mp4", interactive=False)
|
|
|
574 |
return gr.ImageEditor(value=d)
|
575 |
|
576 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
577 |
load_model="""
|
578 |
async(c, o, b, p, d, n, m)=>{
|
579 |
var intv = setInterval(function(){
|
|
|
806 |
mouse.input(fn=draw_mask, show_progress="minimal", inputs=[levels, tolerance, mouse, output_mask], outputs=[output_mask])
|
807 |
apply.click(fn=apply_mask, inputs=[output_mask, bsize], outputs=[output_mask, output_depth, output_frame])
|
808 |
reset.click(fn=reset_mask, inputs=None, outputs=[output_mask, output_depth])
|
809 |
+
|
|
|
|
|
810 |
with gr.Column():
|
811 |
model_type = gr.Dropdown([("small", "vits"), ("base", "vitb"), ("large", "vitl")], type="value", value="vits", label='Model Type')
|
812 |
processed_video = gr.Video(label="Output Video", format="mp4", interactive=False)
|