Update app.py
Browse files
app.py
CHANGED
|
@@ -391,6 +391,14 @@ def get_mesh(image, depth, blur_data, loadall):
|
|
| 391 |
#print('file - ok')
|
| 392 |
return "./TriangleWithoutIndices.gltf", ",".join(mesh_n)
|
| 393 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 394 |
def blur_image(image, depth, blur_data):
|
| 395 |
blur_a = blur_data.split()
|
| 396 |
#print(f'blur data {blur_data}')
|
|
@@ -790,6 +798,12 @@ async(c, o, p, d, n, m, s)=>{
|
|
| 790 |
toggleDisplay("model");
|
| 791 |
}
|
| 792 |
clearInterval(intv);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 793 |
}
|
| 794 |
} catch(e) {alert(e);}
|
| 795 |
}
|
|
@@ -1148,6 +1162,14 @@ with gr.Blocks(css=css, js=js, head=head) as demo:
|
|
| 1148 |
processed_zip = gr.File(label="Output Archive", interactive=False)
|
| 1149 |
depth_video = gr.Video(label="Depth Video", format="mp4", elem_id="depth_video", interactive=False, visible=True)
|
| 1150 |
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")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1151 |
with gr.Tab("Blur"):
|
| 1152 |
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>
|
| 1153 |
<style>
|
|
@@ -1371,7 +1393,7 @@ with gr.Blocks(css=css, js=js, head=head) as demo:
|
|
| 1371 |
return output_video_path + (json.dumps(locations),)
|
| 1372 |
|
| 1373 |
submit.click(on_submit, inputs=[input_video, model_type, blur_in, boffset, bsize, coords], outputs=[processed_video, processed_zip, output_frame, output_mask, output_depth, depth_video, coords])
|
| 1374 |
-
render.click(None, inputs=[coords, mesh_order, output_frame, output_mask, selected, output_depth, output_switch], outputs=
|
| 1375 |
render.click(partial(get_mesh), inputs=[output_frame, output_mask, blur_in, load_all], outputs=[result, mesh_order])
|
| 1376 |
|
| 1377 |
example_files = [["./examples/streetview.mp4", "vits", blurin, 1, 32, example_coords]]
|
|
|
|
| 391 |
#print('file - ok')
|
| 392 |
return "./TriangleWithoutIndices.gltf", ",".join(mesh_n)
|
| 393 |
|
| 394 |
+
|
| 395 |
+
def scene_file(data):
|
| 396 |
+
f = open("./scene.babylon", "w")
|
| 397 |
+
f.write(data)
|
| 398 |
+
f.close()
|
| 399 |
+
return "./scene.babylon"
|
| 400 |
+
|
| 401 |
+
|
| 402 |
def blur_image(image, depth, blur_data):
|
| 403 |
blur_a = blur_data.split()
|
| 404 |
#print(f'blur data {blur_data}')
|
|
|
|
| 798 |
toggleDisplay("model");
|
| 799 |
}
|
| 800 |
clearInterval(intv);
|
| 801 |
+
|
| 802 |
+
|
| 803 |
+
var serializedScene = BABYLON.SceneSerializer.Serialize(BABYLON.Engine.LastCreatedScene);
|
| 804 |
+
var strScene = JSON.stringify(serializedScene);
|
| 805 |
+
|
| 806 |
+
return strScene;
|
| 807 |
}
|
| 808 |
} catch(e) {alert(e);}
|
| 809 |
}
|
|
|
|
| 1162 |
processed_zip = gr.File(label="Output Archive", interactive=False)
|
| 1163 |
depth_video = gr.Video(label="Depth Video", format="mp4", elem_id="depth_video", interactive=False, visible=True)
|
| 1164 |
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")
|
| 1165 |
+
with gr.Accordion(label="Embed in website", open=False):
|
| 1166 |
+
embed_model = gr.Textbox(elem_id="embed_model", label="Include this wherever the model is to appear on the page", interactive=False, value="""
|
| 1167 |
+
<script src='https://preview.babylonjs.com/viewer/babylon.viewer.js'></script>
|
| 1168 |
+
<babylon model='./scene.babylon'></babylon>
|
| 1169 |
+
""")
|
| 1170 |
+
embed_json = gr.JSON(label="Scene", interactive=False)
|
| 1171 |
+
embed_zip = gr.File(label="Scene File", interactive=False)
|
| 1172 |
+
embed_json.change(fn=scene_file, inputs=[embed_json], outputs=[embed_zip])
|
| 1173 |
with gr.Tab("Blur"):
|
| 1174 |
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>
|
| 1175 |
<style>
|
|
|
|
| 1393 |
return output_video_path + (json.dumps(locations),)
|
| 1394 |
|
| 1395 |
submit.click(on_submit, inputs=[input_video, model_type, blur_in, boffset, bsize, coords], outputs=[processed_video, processed_zip, output_frame, output_mask, output_depth, depth_video, coords])
|
| 1396 |
+
render.click(None, inputs=[coords, mesh_order, output_frame, output_mask, selected, output_depth, output_switch], outputs=[embed_json], js=load_model)
|
| 1397 |
render.click(partial(get_mesh), inputs=[output_frame, output_mask, blur_in, load_all], outputs=[result, mesh_order])
|
| 1398 |
|
| 1399 |
example_files = [["./examples/streetview.mp4", "vits", blurin, 1, 32, example_coords]]
|