mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2025-12-21 14:50:36 +08:00
Rendering texturing fixes
Summary: Fix errors raised by issue on GitHub - extending mesh textures + rendering with Gourad and Phong shaders. https://github.com/facebookresearch/pytorch3d/issues/97 Reviewed By: gkioxari Differential Revision: D20319610 fbshipit-source-id: d1c692ff0b9397a77a9b829c5c731790de70c09f
This commit is contained in:
committed by
Facebook GitHub Bot
parent
f580ce1385
commit
5d3cc3569a
@@ -1,6 +1,7 @@
|
||||
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
|
||||
|
||||
|
||||
import numpy as np
|
||||
import unittest
|
||||
import torch
|
||||
|
||||
@@ -61,3 +62,28 @@ class TestTensorProperties(TestCaseMixin, unittest.TestCase):
|
||||
example = TensorPropertiesTestClass(x=(), y=())
|
||||
self.assertTrue(len(example) == 0)
|
||||
self.assertTrue(example.isempty())
|
||||
|
||||
def test_gather_props(self):
|
||||
N = 4
|
||||
x = torch.randn((N, 3, 4))
|
||||
y = torch.randn((N, 5))
|
||||
test_class = TensorPropertiesTestClass(x=x, y=y)
|
||||
|
||||
S = 15
|
||||
idx = torch.tensor(np.random.choice(N, S))
|
||||
test_class_gathered = test_class.gather_props(idx)
|
||||
|
||||
self.assertTrue(test_class_gathered.x.shape == (S, 3, 4))
|
||||
self.assertTrue(test_class_gathered.y.shape == (S, 5))
|
||||
|
||||
for i in range(N):
|
||||
inds = idx == i
|
||||
if inds.sum() > 0:
|
||||
# Check the gathered points in the output have the same value from
|
||||
# the input.
|
||||
self.assertClose(
|
||||
test_class_gathered.x[inds].mean(dim=0), x[i, ...]
|
||||
)
|
||||
self.assertClose(
|
||||
test_class_gathered.y[inds].mean(dim=0), y[i, ...]
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user