(self, weights)
| 239 | return outputs |
| 240 | |
| 241 | def load_weights_from_keras(self, weights): |
| 242 | assert self.use_viewdirs, "Not implemented if use_viewdirs=False" |
| 243 | |
| 244 | # Load pts_linears |
| 245 | for i in range(self.D): |
| 246 | idx_pts_linears = 2 * i |
| 247 | self.pts_linears[i].weight.data = torch.from_numpy(np.transpose(weights[idx_pts_linears])) |
| 248 | self.pts_linears[i].bias.data = torch.from_numpy(np.transpose(weights[idx_pts_linears+1])) |
| 249 | |
| 250 | # Load feature_linear |
| 251 | idx_feature_linear = 2 * self.D |
| 252 | self.feature_linear.weight.data = torch.from_numpy(np.transpose(weights[idx_feature_linear])) |
| 253 | self.feature_linear.bias.data = torch.from_numpy(np.transpose(weights[idx_feature_linear+1])) |
| 254 | |
| 255 | # Load views_linears |
| 256 | idx_views_linears = 2 * self.D + 2 |
| 257 | self.views_linears[0].weight.data = torch.from_numpy(np.transpose(weights[idx_views_linears])) |
| 258 | self.views_linears[0].bias.data = torch.from_numpy(np.transpose(weights[idx_views_linears+1])) |
| 259 | |
| 260 | # Load rgb_linear |
| 261 | idx_rbg_linear = 2 * self.D + 4 |
| 262 | self.rgb_linear.weight.data = torch.from_numpy(np.transpose(weights[idx_rbg_linear])) |
| 263 | self.rgb_linear.bias.data = torch.from_numpy(np.transpose(weights[idx_rbg_linear+1])) |
| 264 | |
| 265 | # Load alpha_linear |
| 266 | idx_alpha_linear = 2 * self.D + 6 |
| 267 | self.alpha_linear.weight.data = torch.from_numpy(np.transpose(weights[idx_alpha_linear])) |
| 268 | self.alpha_linear.bias.data = torch.from_numpy(np.transpose(weights[idx_alpha_linear+1])) |
| 269 | |
| 270 | def create_nerf(args): |
| 271 | """Instantiate NeRF's MLP model. |
nothing calls this directly
no outgoing calls
no test coverage detected