Skip to content

Added Histogram Transformation #796

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Conversation

Miladiouss
Copy link

As I have discussed in a feature request, HistogramTransformation is very useful, especially when handling raw data in photography or astronomy. Please see this gist for its functionality, examples, tests, and proof of concept.

As I have discussed in a feature request (link1), HistogramTransformation is very useful, especially when handling raw data in photography or astronomy. Please see the following gits (link2) for its functionality, examples, and proof of concept.

link1: pytorch#598
link2: https://gist.github.com/Miladiouss/86bed5c53595116dfe18ee0a5c84f838
Copy link
Contributor

@ekagra-ranjan ekagra-ranjan left a comment

Choose a reason for hiding this comment

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

As requested in #598 except for np.interp all the other usage of numpy as can be replace by a torch equivalent.

tensor = tensor.ravel()

# Get counts, bins, and corresponding bin indices for each tensor value
counts, bins = np.histogram(tensor, bins = t_bins)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you change this to torch equivalent torch.histc()?

Copy link
Author

Choose a reason for hiding this comment

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

Unfortunately not; mainly because np.histogram accepts variable bin interval while torch.histc can only handle equal bin interval. Also, that would require conversion between np.array and torch.tensor multiple times.

@codecov-io
Copy link

codecov-io commented Mar 12, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@44a5bae). Click here to learn what that means.
The diff coverage is 12.9%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #796   +/-   ##
=========================================
  Coverage          ?   37.86%           
=========================================
  Files             ?       32           
  Lines             ?     3159           
  Branches          ?      490           
=========================================
  Hits              ?     1196           
  Misses            ?     1884           
  Partials          ?       79
Impacted Files Coverage Δ
torchvision/transforms/transforms.py 78.64% <12.9%> (ø)

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 44a5bae...7be9f4b. Read the comment docs.

Milad Pourrahmani added 5 commits March 12, 2019 16:11
I used a code beautifier to get rid of spacing errors raised by flake8.
@Miladiouss
Copy link
Author

I am not familiar with codecov. Can someone please help me pass the checks?

@zhunzhong07
Copy link
Contributor

@Miladiouss You should also add test code in test/test_transforms.py. You can find examples at this file.

@zakajd zakajd mentioned this pull request Aug 7, 2019
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.

4 participants