Spaces:
Running
on
Zero
Running
on
Zero
support meta json file download
Browse files
app.py
CHANGED
|
@@ -232,9 +232,6 @@ def SRT_quat_to_matrix(scale, quat, translation):
|
|
| 232 |
|
| 233 |
def write_output(primitives, name):
|
| 234 |
out_json = {}
|
| 235 |
-
out_json['operation'] = 0
|
| 236 |
-
out_json['type'] = 1
|
| 237 |
-
out_json['scene_id'] = None
|
| 238 |
|
| 239 |
new_group = []
|
| 240 |
model_scene = trimesh.Scene()
|
|
@@ -255,7 +252,6 @@ def write_output(primitives, name):
|
|
| 255 |
new_block['data']['location'] = translation.tolist()
|
| 256 |
new_block['data']['rotation'] = euler_to_quat(rotation).tolist()
|
| 257 |
new_block['data']['scale'] = scale.tolist()
|
| 258 |
-
new_block['data']['color'] = ['808080']
|
| 259 |
new_group.append(new_block)
|
| 260 |
|
| 261 |
trans = SRT_quat_to_matrix(scale, euler_to_quat(rotation), translation)
|
|
@@ -344,7 +340,13 @@ def process_3d_model(input_3d, dilated_offset, do_marching_cubes, postprocess_me
|
|
| 344 |
do_marching_cubes=do_marching_cubes,
|
| 345 |
postprocess=postprocess_method
|
| 346 |
)
|
| 347 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 348 |
# except Exception as e:
|
| 349 |
# return f"Error processing file: {str(e)}"
|
| 350 |
|
|
@@ -394,12 +396,13 @@ with gr.Blocks(title="PrimitiveAnything: Human-Crafted 3D Primitive Assembly Gen
|
|
| 394 |
|
| 395 |
with gr.Column():
|
| 396 |
# Output components
|
| 397 |
-
|
|
|
|
| 398 |
|
| 399 |
submit_btn.click(
|
| 400 |
fn=process_3d_model,
|
| 401 |
inputs=[input_3d, dilated_offset, do_marching_cubes],
|
| 402 |
-
outputs=
|
| 403 |
)
|
| 404 |
|
| 405 |
|
|
|
|
| 232 |
|
| 233 |
def write_output(primitives, name):
|
| 234 |
out_json = {}
|
|
|
|
|
|
|
|
|
|
| 235 |
|
| 236 |
new_group = []
|
| 237 |
model_scene = trimesh.Scene()
|
|
|
|
| 252 |
new_block['data']['location'] = translation.tolist()
|
| 253 |
new_block['data']['rotation'] = euler_to_quat(rotation).tolist()
|
| 254 |
new_block['data']['scale'] = scale.tolist()
|
|
|
|
| 255 |
new_group.append(new_block)
|
| 256 |
|
| 257 |
trans = SRT_quat_to_matrix(scale, euler_to_quat(rotation), translation)
|
|
|
|
| 340 |
do_marching_cubes=do_marching_cubes,
|
| 341 |
postprocess=postprocess_method
|
| 342 |
)
|
| 343 |
+
|
| 344 |
+
# Save JSON to a file
|
| 345 |
+
json_path = os.path.join(LOG_PATH, f'output_{os.path.basename(input_3d)[:-4]}.json')
|
| 346 |
+
with open(json_path, 'w') as f:
|
| 347 |
+
json.dump(output_model_json, f, indent=4)
|
| 348 |
+
|
| 349 |
+
return output_model_obj, json_path
|
| 350 |
# except Exception as e:
|
| 351 |
# return f"Error processing file: {str(e)}"
|
| 352 |
|
|
|
|
| 396 |
|
| 397 |
with gr.Column():
|
| 398 |
# Output components
|
| 399 |
+
output_3d = gr.Model3D(label="Primitive Assembly Prediction")
|
| 400 |
+
output_json = gr.File(label="Download JSON File")
|
| 401 |
|
| 402 |
submit_btn.click(
|
| 403 |
fn=process_3d_model,
|
| 404 |
inputs=[input_3d, dilated_offset, do_marching_cubes],
|
| 405 |
+
outputs=[output_3d, output_json]
|
| 406 |
)
|
| 407 |
|
| 408 |
|