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

[Datasets] [AIR] Add TorchVisionPreprocessor #30403

Closed
bveeramani opened this issue Nov 17, 2022 · 0 comments · Fixed by #30578
Closed

[Datasets] [AIR] Add TorchVisionPreprocessor #30403

bveeramani opened this issue Nov 17, 2022 · 0 comments · Fixed by #30578
Assignees
Labels
data Ray Data-related issues enhancement Request for new feature and/or capability P1 Issue that should be fixed within a few weeks

Comments

@bveeramani
Copy link
Member

Description

Add a preprocessor like

TorchVisionTransformer(transform: Callable[[], torch.Tensor], columns: list[str])

that applies TorchVision transforms.

Use case

To apply a simple TorchVision transform like:

transform = Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]) 

You need to something like this:

def map_fn(batch: dict[str, np.ndarray]) -> dict[str, np.ndarray]:
    return {"image": np.array([transform(image).numpy() for image in batch], dtype=object)}

which is complicated.

With a TorchVisionTransformer, you could instead do:

TorchVisionTransformer(transform, columns="image")

which is simpler.

@bveeramani bveeramani added enhancement Request for new feature and/or capability air data Ray Data-related issues labels Nov 17, 2022
@bveeramani bveeramani self-assigned this Nov 17, 2022
@clarkzinzow clarkzinzow added the P1 Issue that should be fixed within a few weeks label Nov 18, 2022
richardliaw pushed a commit that referenced this issue Jan 4, 2023
Co-authored-by: Clark Zinzow <clarkzinzow@gmail.com>
Closes #30403
AmeerHajAli pushed a commit that referenced this issue Jan 12, 2023
Co-authored-by: Clark Zinzow <clarkzinzow@gmail.com>
Closes #30403
tamohannes pushed a commit to ju2ez/ray that referenced this issue Jan 25, 2023
Co-authored-by: Clark Zinzow <clarkzinzow@gmail.com>
Closes ray-project#30403

Signed-off-by: tmynn <hovhannes.tamoyan@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data Ray Data-related issues enhancement Request for new feature and/or capability P1 Issue that should be fixed within a few weeks
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants