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
This commit is contained in:
Jeremy Reizenstein 2020-10-29 10:15:17 -07:00 committed by Facebook GitHub Bot
parent aa4cc0adbc
commit 0e5f4f7660
2 changed files with 5 additions and 20 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 95 KiB

View File

@ -2,13 +2,10 @@
import unittest
from pathlib import Path
import numpy as np
import torch
import torch.nn.functional as F
from common_testing import TestCaseMixin
from PIL import Image
from pytorch3d.renderer.mesh.rasterizer import Fragments
from pytorch3d.renderer.mesh.textures import (
TexturesAtlas,
@ -18,14 +15,9 @@ from pytorch3d.renderer.mesh.textures import (
pack_rectangles,
)
from pytorch3d.structures import Meshes, list_to_packed, packed_to_list
from pytorch3d.vis import texturesuv_image_PIL
from test_meshes import TestMeshes
DEBUG = False
DATA_DIR = Path(__file__).resolve().parent / "data"
def tryindex(self, index, tex, meshes, source):
tex2 = tex[index]
meshes2 = meshes[index]
@ -833,21 +825,14 @@ class TestTexturesUV(TestCaseMixin, unittest.TestCase):
tryindex(self, index, tex, meshes, source)
tryindex(self, [2, 4], tex, meshes, source)
def test_png_debug(self):
maps = torch.rand(size=(1, 256, 128, 3)) * torch.tensor([0.8, 1, 0.8])
verts_uvs = torch.rand(size=(1, 20, 2))
def test_centers_for_image(self):
maps = torch.rand(size=(1, 257, 129, 3))
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)
tex = TexturesUV(maps=maps, faces_uvs=faces_uvs, verts_uvs=verts_uvs)
image = texturesuv_image_PIL(tex, radius=3)
image_out = np.array(image)
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)
expected = torch.FloatTensor([[32, 224], [64, 96], [64, 128]])
self.assertClose(tex.centers_for_image(0), expected)
class TestRectanglePacking(TestCaseMixin, unittest.TestCase):