Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove torchvision.io from test_utils.py #3092

Merged
merged 1 commit into from
Dec 2, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions test/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import numpy as np
import os
import sys
import tempfile
Expand All @@ -6,7 +7,6 @@
import unittest
from io import BytesIO
import torchvision.transforms.functional as F
from torchvision.io.image import read_image, write_png
from PIL import Image


Expand Down Expand Up @@ -90,9 +90,10 @@ def test_draw_boxes(self):

path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "assets", "fakedata", "draw_boxes_util.png")
if not os.path.exists(path):
write_png(result, path)
res = Image.fromarray(result.permute(1, 2, 0).contiguous().numpy())
res.save(path)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was recently changed based on your comment. What's the issue using the io.image here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, my bad sorry about that.

Internal fb tests were failing because this test now imposes that the image part of torchvision is compiled, and we would need to adapt some TARGETS file for that. In order to move forward with fbcode integration, it's easier to first change to using PIL, then update the TARGETS file in fbcode and then add back the dependency to torchvision.io.


expected = read_image(path)
expected = torch.as_tensor(np.array(Image.open(path))).permute(2, 0, 1)
self.assertTrue(torch.equal(result, expected))


Expand Down