-
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-87] Add type annotations for python/paddle/vision/datasets/flowers.py
#65504
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
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.
这个错误
2024-06-27 09:50:04 paddle.vision.datasets.Flowers:1
2024-06-27 09:50:04 <string>:30:22: error: Item "Image" of "Union[Tensor, Image, ndarray[Any, dtype[Any]]]" has no attribute "shape" [union-attr]
2024-06-27 09:50:04 Found 1 error in 1 file (checked 1 source file)
目前我能想到的解决办法:
- 在示例中的
... print(type(img), img.shape, label)
加上# type: ignore
- 用
cast
:... print(type(img), cast(Tensor, img).shape, label)
@SigureMo 帮忙看看?
@@ -167,7 +187,7 @@ def __init__( | |||
self.labels = scio.loadmat(label_file)['labels'][0] | |||
self.indexes = scio.loadmat(setid_file)[flag][0] | |||
|
|||
def __getitem__(self, idx): | |||
def __getitem__(self, idx: int) -> tuple[_ImageDataType, npt.NDArray[Any]]: |
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.
def __getitem__(self, idx: int) -> tuple[_ImageDataType, npt.NDArray[Any]]: | |
def __getitem__(self, idx: int) -> tuple[_ImageDataType, npt.NDArray[np.int64]]: |
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.
收到
ignore 吧 |
加错地方了,注意下行号 |
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-87