towhee
/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Readme
Files and versions
29 lines
926 B
29 lines
926 B
3 years ago
|
import unittest
|
||
|
from PIL import Image
|
||
|
from torchvision import transforms
|
||
|
from transform_image_operator_template import TransformImageOperatorTemplate
|
||
|
from config import TEST_IMG, SIZE
|
||
|
|
||
|
|
||
|
class TestTransformImageOperatorTemplate(unittest.TestCase):
|
||
|
test_img = Image.open(TEST_IMG)
|
||
|
tfms = transforms.Compose(
|
||
|
[
|
||
|
transforms.Resize(SIZE),
|
||
|
transforms.CenterCrop(224),
|
||
|
transforms.ToTensor(),
|
||
|
transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]),
|
||
|
]
|
||
|
)
|
||
|
img1 = tfms(test_img).unsqueeze(0)
|
||
|
|
||
|
def test_transform_image(self):
|
||
|
op = TransformImageOperatorTemplate(SIZE)
|
||
|
outputs = op(self.test_img)
|
||
|
print("The output tyep of operator:", type(outputs.img_transformed))
|
||
|
c = (self.img1.numpy() == outputs.img_transformed.numpy())
|
||
|
self.assertEqual(c.all(), True)
|
||
|
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
unittest.main()
|