diff --git a/README.md b/README.md index 06884ed..f1a73d2 100644 --- a/README.md +++ b/README.md @@ -23,12 +23,12 @@ __init__(self, size: int) - supported types: `int` ```python -int__call__(self, img: Union[Image.Image, torch.Tensor, str]) +int__call__(self, img_path: Union[Image.Image, torch.Tensor, str]) ``` **Args:** -- img: +- img_path: - the input image to be processed - supported type: `PIL.image`, `torch.Tensor` or `str` (path of the image) @@ -46,8 +46,6 @@ You can get the required python package by [requirements.txt](https://zilliverse ## **How it works** -The `towhee/transform-image-operator-template` Operator is used for image transformation and is an important part of data preprocessing. It can be added to the pipeline and is usually used as the first custom operator of the pipeline. For example, it's the first Operator named processing within [image-embedding-pipeline-template](https://hub.towhee.io/towhee/image-embedding-pipeline-template) pipeline, and it is the red box in the picture below. - -![img](./readme_res/operator.png) +The `towhee/transform-image-operator-template` Operator is used for image transformation and is an important part of data preprocessing. It can be added to the pipeline and is usually used as the first custom operator of the pipeline. For example, it's the first Operator named processing within [image-embedding-pipeline-template](https://hub.towhee.io/towhee/image-embedding-pipeline-template) pipeline. ## **Reference** diff --git a/readme_res/operator.png b/readme_res/operator.png deleted file mode 100644 index 3311d5e..0000000 Binary files a/readme_res/operator.png and /dev/null differ diff --git a/test_transform_image_operator_template.py b/test_transform_image_operator_template.py index 23d8b6d..83385e8 100644 --- a/test_transform_image_operator_template.py +++ b/test_transform_image_operator_template.py @@ -6,7 +6,6 @@ from config import TEST_IMG, SIZE class TestTransformImageOperatorTemplate(unittest.TestCase): - test_img = Image.open(TEST_IMG) tfms = transforms.Compose( [ transforms.Resize(SIZE), @@ -19,7 +18,7 @@ class TestTransformImageOperatorTemplate(unittest.TestCase): def test_transform_image(self): op = TransformImageOperatorTemplate(SIZE) - outputs = op(self.test_img) + outputs = op(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) diff --git a/transform_image_operator_template.py b/transform_image_operator_template.py index 7065324..647cdcb 100644 --- a/transform_image_operator_template.py +++ b/transform_image_operator_template.py @@ -29,7 +29,7 @@ class TransformImageOperatorTemplate(Operator): super().__init__() #user defined initialization - def __call__(self, img: Union[Image.Image, torch.Tensor, str]) -> NamedTuple('Outputs', [('img_transformed', torch.Tensor)]): + def __call__(self, img_path: Union[Image.Image, torch.Tensor, str]) -> NamedTuple('Outputs', [('img_transformed', torch.Tensor)]): results = #user defined function: get the transformed image Outputs = NamedTuple('Outputs', [('img_transformed', torch.Tensor)]) return Outputs(results) diff --git a/transform_image_operator_template.yaml b/transform_image_operator_template.yaml index 835b1c1..cc546d2 100644 --- a/transform_image_operator_template.yaml +++ b/transform_image_operator_template.yaml @@ -8,6 +8,6 @@ init: size: int call: input: - img: Union[Image.Image, torch.Tensor, str] + img_path: Union[Image.Image, torch.Tensor, str] output: img_transformed: torch.Tensor \ No newline at end of file