Spaces:
mashroo
/
Running on Zero

YoussefAnso commited on
Commit
db2fd1d
·
1 Parent(s): d65fe1c

Enhance generate3d function to initialize nvdiffrast context for mesh export, improving rendering capabilities. Updated export call to include rendering context and adjusted parameters for UVs and texture image, ensuring better integration with the model.

Browse files
Files changed (1) hide show
  1. inference.py +9 -2
inference.py CHANGED
@@ -18,8 +18,15 @@ def generate3d(model, rgb_image, xyz_image, device="cpu"):
18
  # CRM export expects a data dictionary
19
  data = {"rgb": rgb_image, "xyz": xyz_image}
20
 
21
- # Export mesh using CRM model
22
- model.export_mesh_wt_uv(data, output_dir, 0, device, 1024)
 
 
 
 
 
 
 
23
 
24
  # Convert .obj to .glb
25
  mesh = Mesh.load(obj_path, device=torch.device("cpu"))
 
18
  # CRM export expects a data dictionary
19
  data = {"rgb": rgb_image, "xyz": xyz_image}
20
 
21
+ # Get rendering context required by xatlas and nvdiffrast
22
+ try:
23
+ import nvdiffrast.torch as dr
24
+ ctx = dr.RasterizeGLContext()
25
+ except Exception as e:
26
+ raise RuntimeError("Failed to initialize nvdiffrast context: " + str(e))
27
+
28
+ # Export mesh with UVs and texture image
29
+ model.export_mesh_wt_uv(ctx, data, base_path, 0, device, 512)
30
 
31
  # Convert .obj to .glb
32
  mesh = Mesh.load(obj_path, device=torch.device("cpu"))