Commit 0e5f4f76 authored by Jeremy Reizenstein's avatar Jeremy Reizenstein Committed by Facebook GitHub Bot
Browse files

remove texture_vis test

Summary: This recently added test is sensitive to the version of PIL because of different algorithms to draw ellipses/circles. Remove it as there is no obvious safe way to test this. Replace with a test for the underlying centres_for_image().

Reviewed By: theschnitz

Differential Revision: D24622465

fbshipit-source-id: e46d7384df491c71ac87ba8bbbce89507ac40080
parent aa4cc0ad
...@@ -2,13 +2,10 @@ ...@@ -2,13 +2,10 @@
import unittest import unittest
from pathlib import Path
import numpy as np
import torch import torch
import torch.nn.functional as F import torch.nn.functional as F
from common_testing import TestCaseMixin from common_testing import TestCaseMixin
from PIL import Image
from pytorch3d.renderer.mesh.rasterizer import Fragments from pytorch3d.renderer.mesh.rasterizer import Fragments
from pytorch3d.renderer.mesh.textures import ( from pytorch3d.renderer.mesh.textures import (
TexturesAtlas, TexturesAtlas,
...@@ -18,14 +15,9 @@ from pytorch3d.renderer.mesh.textures import ( ...@@ -18,14 +15,9 @@ from pytorch3d.renderer.mesh.textures import (
pack_rectangles, pack_rectangles,
) )
from pytorch3d.structures import Meshes, list_to_packed, packed_to_list from pytorch3d.structures import Meshes, list_to_packed, packed_to_list
from pytorch3d.vis import texturesuv_image_PIL
from test_meshes import TestMeshes from test_meshes import TestMeshes
DEBUG = False
DATA_DIR = Path(__file__).resolve().parent / "data"
def tryindex(self, index, tex, meshes, source): def tryindex(self, index, tex, meshes, source):
tex2 = tex[index] tex2 = tex[index]
meshes2 = meshes[index] meshes2 = meshes[index]
...@@ -833,21 +825,14 @@ class TestTexturesUV(TestCaseMixin, unittest.TestCase): ...@@ -833,21 +825,14 @@ class TestTexturesUV(TestCaseMixin, unittest.TestCase):
tryindex(self, index, tex, meshes, source) tryindex(self, index, tex, meshes, source)
tryindex(self, [2, 4], tex, meshes, source) tryindex(self, [2, 4], tex, meshes, source)
def test_png_debug(self): def test_centers_for_image(self):
maps = torch.rand(size=(1, 256, 128, 3)) * torch.tensor([0.8, 1, 0.8]) maps = torch.rand(size=(1, 257, 129, 3))
verts_uvs = torch.rand(size=(1, 20, 2)) verts_uvs = torch.FloatTensor([[[0.25, 0.125], [0.5, 0.625], [0.5, 0.5]]])
faces_uvs = torch.zeros(size=(1, 0, 3), dtype=torch.int64) faces_uvs = torch.zeros(size=(1, 0, 3), dtype=torch.int64)
tex = TexturesUV(maps=maps, faces_uvs=faces_uvs, verts_uvs=verts_uvs) tex = TexturesUV(maps=maps, faces_uvs=faces_uvs, verts_uvs=verts_uvs)
image = texturesuv_image_PIL(tex, radius=3) expected = torch.FloatTensor([[32, 224], [64, 96], [64, 128]])
image_out = np.array(image) self.assertClose(tex.centers_for_image(0), expected)
if DEBUG:
image.save(DATA_DIR / "texturesuv_debug_.png")
with Image.open(DATA_DIR / "texturesuv_debug.png") as image_ref_file:
image_ref = np.array(image_ref_file)
self.assertClose(image_out, image_ref)
class TestRectanglePacking(TestCaseMixin, unittest.TestCase): class TestRectanglePacking(TestCaseMixin, unittest.TestCase):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment