forked from wgsxm/PartCrafter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrender.py
More file actions
41 lines (34 loc) · 1.17 KB
/
render.py
File metadata and controls
41 lines (34 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import os
import trimesh
import numpy as np
import argparse
import json
from src.utils.data_utils import normalize_mesh
from src.utils.render_utils import render_single_view
RADIUS = 4
IMAGE_SIZE = (2048, 2048)
LIGHT_INTENSITY = 2.5
NUM_ENV_LIGHTS = 36
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--input', type=str, default='assets/objects/scissors.glb')
parser.add_argument('--output', type=str, default='preprocessed_data')
args = parser.parse_args()
input_path = args.input
output_path = args.output
assert os.path.exists(input_path), f'{input_path} does not exist'
mesh_name = os.path.basename(input_path).split('.')[0]
output_path = os.path.join(output_path, mesh_name)
if not os.path.exists(output_path):
os.makedirs(output_path)
mesh = normalize_mesh(trimesh.load(input_path, process=False))
mesh = mesh.to_geometry()
image = render_single_view(
mesh,
radius=RADIUS,
image_size=IMAGE_SIZE,
light_intensity=LIGHT_INTENSITY,
num_env_lights=NUM_ENV_LIGHTS,
return_type='pil'
)
image.save(os.path.join(output_path, f'rendering.png'))