Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -329,14 +329,7 @@ def get_mesh(image, depth, blur_data, loadall, dcolor):
|
|
329 |
glb_file = tempfile.NamedTemporaryFile(suffix='.glb', delete=False)
|
330 |
scene.export(glb_file.name)
|
331 |
print('file - ok')
|
332 |
-
|
333 |
-
bg = json.loads(dcolor)
|
334 |
-
j = 0
|
335 |
-
while j < len(bg):
|
336 |
-
bg[j] = bg[j] / 255
|
337 |
-
j=j+1
|
338 |
-
print(bg)
|
339 |
-
return gr.Model3D(value=glb_file.name, clear_color=bg), glb_file.name, ",".join(mesh_n)
|
340 |
|
341 |
def blur_image(image, depth, blur_data):
|
342 |
blur_a = blur_data.split()
|
@@ -553,11 +546,16 @@ async(f, c, o, b)=>{
|
|
553 |
"""
|
554 |
|
555 |
on_click="""
|
556 |
-
async()=>{
|
557 |
var intv = setInterval(function(){
|
558 |
if (document.getElementById("iframe3D")===null || typeof document.getElementById("iframe3D")==="undefined") {
|
559 |
if (BABYLON && BABYLON.Engine.LastCreatedScene) {
|
560 |
BABYLON.Engine.LastCreatedScene.onAfterRenderObservable.add(function() { //onDataLoadedObservable
|
|
|
|
|
|
|
|
|
|
|
561 |
for (var i=0; i<BABYLON.Engine.LastCreatedScene.getNodes().length; i++) {
|
562 |
if (BABYLON.Engine.LastCreatedScene.getNodes()[i].material) {
|
563 |
BABYLON.Engine.LastCreatedScene.getNodes()[i].material.pointSize = Math.ceil(Math.log2(Math.PI/document.getElementById("zoom").value));
|
@@ -1070,7 +1068,6 @@ with gr.Blocks(css=css, js=js) as demo:
|
|
1070 |
<canvas id='cnv_out'/>""")
|
1071 |
load_all = gr.Checkbox(label="Load all")
|
1072 |
render = gr.Button("Render")
|
1073 |
-
render.click(None, inputs=None, outputs=None, js=on_click)
|
1074 |
input_json.input(show_json, inputs=[input_json], outputs=[processed_video, processed_zip, output_frame, output_mask, coords])
|
1075 |
|
1076 |
def on_submit(uploaded_video,model_type,coordinates):
|
@@ -1110,7 +1107,7 @@ with gr.Blocks(css=css, js=js) as demo:
|
|
1110 |
return output_video_path + (json.dumps(locations),)
|
1111 |
|
1112 |
submit.click(on_submit, inputs=[input_video, model_type, coords], outputs=[processed_video, processed_zip, output_frame, output_mask, coords])
|
1113 |
-
render.click(partial(get_mesh), inputs=[output_frame, output_mask, blur_in, load_all, bgcolor], outputs=[result, result_file, mesh_order])
|
1114 |
|
1115 |
example_files = os.listdir('examples')
|
1116 |
example_files.sort()
|
|
|
329 |
glb_file = tempfile.NamedTemporaryFile(suffix='.glb', delete=False)
|
330 |
scene.export(glb_file.name)
|
331 |
print('file - ok')
|
332 |
+
return glb_file.name, glb_file.name, ",".join(mesh_n)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
333 |
|
334 |
def blur_image(image, depth, blur_data):
|
335 |
blur_a = blur_data.split()
|
|
|
546 |
"""
|
547 |
|
548 |
on_click="""
|
549 |
+
async(of, om, bi, la, bg)=>{
|
550 |
var intv = setInterval(function(){
|
551 |
if (document.getElementById("iframe3D")===null || typeof document.getElementById("iframe3D")==="undefined") {
|
552 |
if (BABYLON && BABYLON.Engine.LastCreatedScene) {
|
553 |
BABYLON.Engine.LastCreatedScene.onAfterRenderObservable.add(function() { //onDataLoadedObservable
|
554 |
+
var bg = JSON.parse(bg);
|
555 |
+
for (var i=0; i<bg.length; i++) {
|
556 |
+
bg[i] /= 255;
|
557 |
+
}
|
558 |
+
BABYLON.Engine.LastCreatedScene.clearColor = new BABYLON.Color4(bg[0], bg[1], bg[2], bg[3]);
|
559 |
for (var i=0; i<BABYLON.Engine.LastCreatedScene.getNodes().length; i++) {
|
560 |
if (BABYLON.Engine.LastCreatedScene.getNodes()[i].material) {
|
561 |
BABYLON.Engine.LastCreatedScene.getNodes()[i].material.pointSize = Math.ceil(Math.log2(Math.PI/document.getElementById("zoom").value));
|
|
|
1068 |
<canvas id='cnv_out'/>""")
|
1069 |
load_all = gr.Checkbox(label="Load all")
|
1070 |
render = gr.Button("Render")
|
|
|
1071 |
input_json.input(show_json, inputs=[input_json], outputs=[processed_video, processed_zip, output_frame, output_mask, coords])
|
1072 |
|
1073 |
def on_submit(uploaded_video,model_type,coordinates):
|
|
|
1107 |
return output_video_path + (json.dumps(locations),)
|
1108 |
|
1109 |
submit.click(on_submit, inputs=[input_video, model_type, coords], outputs=[processed_video, processed_zip, output_frame, output_mask, coords])
|
1110 |
+
render.click(partial(get_mesh), inputs=[output_frame, output_mask, blur_in, load_all, bgcolor], outputs=[result, result_file, mesh_order], js=on_click)
|
1111 |
|
1112 |
example_files = os.listdir('examples')
|
1113 |
example_files.sort()
|