-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
[Typing][A-88] Add type annotations for python/paddle/vision/datasets/folder.py
#65532
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
示例中有两个地方可能要 ignore 一下: >>> data_folder_2 = DatasetFolder(
... fake_data_dir,
... loader=lambda x: cv2.imread(x), # load image with OpenCV
... extensions=(".jpg",), # type: ignore # only load *.jpg files
... transform=transform, # apply transform to every image
... )
>>> print([img_path for img_path, label in data_folder_2.samples])
>>> # doctest: +SKIP(it's different with windows)
['./temp_dir/class_0/abc.jpg', './temp_dir/class_1/mno/stu.jpg']
>>> # doctest: -SKIP
>>> print(len(data_folder_2))
2
>>> for img, label in iter(data_folder_2):
... # do something with img and label
... print(type(img), img.shape, label) # type: ignore
... # <class 'paddle.Tensor'> [3, 64, 64] 0 |
ImageFolder 的示例也要改一下滴 ~~~ |
... print(type(img), img.size) # type: ignore 这里是不需要 ignore 的,而 ... print(type(img), img.shape) 这里需要 ~ 主要是因为 mypy 会检查无用的 ignore,所以报错了 |
收到,谢谢解惑。 |
CI 报错得看看 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Category
User Experience
PR Types
Improvements
Description
A-88