YulianSa commited on
Commit
e6bf151
·
1 Parent(s): 1570031
Files changed (1) hide show
  1. infer_api.py +22 -0
infer_api.py CHANGED
@@ -99,6 +99,28 @@ weight_dtype = torch.float16
99
  device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
100
  VIEWS = ['front', 'front_right', 'right', 'back', 'left', 'front_left']
101
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
  repo_id = "hyz317/StdGEN"
103
  all_files = list_repo_files(repo_id, revision="main")
104
  for file in all_files:
 
99
  device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
100
  VIEWS = ['front', 'front_right', 'right', 'back', 'left', 'front_left']
101
 
102
+
103
+ #### TEST ####
104
+ import nvdiffrast.torch as dr
105
+ import torch
106
+ from typing import Tuple
107
+
108
+ @spaces.GPU
109
+ def _warmup(glctx, device=None):
110
+ device = 'cuda' if device is None else device
111
+ #windows workaround for https://github.com/NVlabs/nvdiffrast/issues/59
112
+ def tensor(*args, **kwargs):
113
+ return torch.tensor(*args, device=device, **kwargs)
114
+ pos = tensor([[[-0.8, -0.8, 0, 1], [0.8, -0.8, 0, 1], [-0.8, 0.8, 0, 1]]], dtype=torch.float32)
115
+ tri = tensor([[0, 1, 2]], dtype=torch.int32)
116
+ dr.rasterize(glctx, pos, tri, resolution=[256, 256])
117
+
118
+ _glctx = dr.RasterizeCudaContext(device=None)
119
+ _warmup(_glctx, device)
120
+
121
+ #### TEST END ####
122
+
123
+
124
  repo_id = "hyz317/StdGEN"
125
  all_files = list_repo_files(repo_id, revision="main")
126
  for file in all_files: