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

Pytorch transform api #1337

Merged
merged 13 commits into from
Nov 25, 2021
Merged

Pytorch transform api #1337

merged 13 commits into from
Nov 25, 2021

Conversation

AbhinavTuli
Copy link
Contributor

🚀 🚀 Pull Request

Checklist:

  • My code follows the style guidelines of this project and the Contributing document
  • I have commented my code, particularly in hard-to-understand areas
  • I have kept the coverage-rate up
  • I have performed a self-review of my own code and resolved any problems
  • I have checked to ensure there aren't any other open Pull Requests for the same change
  • I have described and made corresponding changes to the relevant documentation
  • New and existing unit tests pass locally with my changes

Changes

Allows another way to specify pytorch transforms using a dictionary instead of a function that is applied on the entire resultant dictionary of data returned by pytorch. The old way is still supported.

For example:-

# ds has image, label and mask as 3 tensors
ptds = ds.pytorch(transform = {"image" : rotate, "label": None})

# this will transform images, return labels as it is and not return masks. 

@CLAassistant
Copy link

CLAassistant commented Nov 10, 2021

CLA assistant check
All committers have signed the CLA.

@codecov
Copy link

codecov bot commented Nov 11, 2021

Codecov Report

Merging #1337 (a1888de) into main (d43ec3c) will increase coverage by 0.72%.
The diff coverage is 98.59%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1337      +/-   ##
==========================================
+ Coverage   90.07%   90.80%   +0.72%     
==========================================
  Files         146      146              
  Lines       10326    10533     +207     
==========================================
+ Hits         9301     9564     +263     
+ Misses       1025      969      -56     
Flag Coverage Δ
unittests 90.80% <98.59%> (+0.72%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
hub/integrations/pytorch/common.py 85.71% <96.55%> (+24.17%) ⬆️
hub/core/io.py 97.25% <100.00%> (-0.12%) ⬇️
hub/integrations/pytorch/dataset.py 91.49% <100.00%> (ø)
hub/integrations/pytorch/pytorch.py 86.20% <100.00%> (+2.20%) ⬆️
hub/integrations/tests/test_pytorch.py 100.00% <100.00%> (ø)
hub/integrations/tests/test_pytorch_dataloader.py 95.69% <100.00%> (+0.76%) ⬆️
hub/core/lock.py 82.22% <0.00%> (-8.89%) ⬇️
hub/cli/commands.py 100.00% <0.00%> (ø)
hub/api/tests/test_json.py 100.00% <0.00%> (ø)
hub/api/tests/test_text.py 100.00% <0.00%> (ø)
... and 36 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d43ec3c...a1888de. Read the comment docs.

@farizrahman4u farizrahman4u merged commit 92cd5a9 into main Nov 25, 2021
@farizrahman4u farizrahman4u deleted the pytorch_transform_api branch November 25, 2021 15:33
@alphazero
Copy link

@AbhinavTuli @farizrahman4u @aliubimov Going forward please prefix all PRs and related commit logs with Jira [ticket-id].

dataset = ShufflingIterableDataset(
mock_dataset(ds), use_local_cache=False, num_workers=4
mock_dataset(ds), use_local_cache=False, num_workers=4, tensors=tensors

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit tedious but better practice to not hardcode values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants