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

Add encoding and writing PNG ops #2726

Merged
merged 18 commits into from
Sep 29, 2020
Merged

Add encoding and writing PNG ops #2726

merged 18 commits into from
Sep 29, 2020

Conversation

andfoy
Copy link
Contributor

@andfoy andfoy commented Sep 29, 2020

This PR introduces new encoding and writing operators to the torchvision image frontend, as follows:

  • encode_png: Takes a CHW tensor as input and produces a byte buffer containing the PNG file in tensor form.
  • write_png: Takes a CHW tensor and a filename and writes the image into a PNG file in disk.

@codecov
Copy link

codecov bot commented Sep 29, 2020

Codecov Report

Merging #2726 into master will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2726      +/-   ##
==========================================
+ Coverage   72.91%   72.93%   +0.01%     
==========================================
  Files          95       95              
  Lines        8233     8238       +5     
  Branches     1279     1279              
==========================================
+ Hits         6003     6008       +5     
  Misses       1838     1838              
  Partials      392      392              
Impacted Files Coverage Δ
torchvision/io/image.py 80.00% <100.00%> (+2.00%) ⬆️

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 6f75883...ba1c2ce. Read the comment docs.

Copy link
Member

@fmassa fmassa left a comment

Choose a reason for hiding this comment

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

Thanks!

@fmassa fmassa merged commit f8780e2 into pytorch:master Sep 29, 2020
@andfoy andfoy deleted the write_png branch September 29, 2020 15:34
bryant1410 pushed a commit to bryant1410/vision-1 that referenced this pull request Nov 22, 2020
* Add encode/write_png functions

* Do not redefine

* Style issues correction

* Comply with low-level interface

* Minor comment correction

* Add python frontend functions

* Add encode_png test

* Pass compession level to encode_png

* Do not compare output buffers

* Convert to bytes

* Compare pil image instead of buffer

* Add error tests

* Add test_write_png

* Remove png test assets

* Register writePNG correctly

* Update write_png docstring

* Do not preserve PIL image beyond the scope

Co-authored-by: Francisco Massa <[email protected]>
vfdev-5 pushed a commit to Quansight/vision that referenced this pull request Dec 4, 2020
* Add encode/write_png functions

* Do not redefine

* Style issues correction

* Comply with low-level interface

* Minor comment correction

* Add python frontend functions

* Add encode_png test

* Pass compession level to encode_png

* Do not compare output buffers

* Convert to bytes

* Compare pil image instead of buffer

* Add error tests

* Add test_write_png

* Remove png test assets

* Register writePNG correctly

* Update write_png docstring

* Do not preserve PIL image beyond the scope

Co-authored-by: Francisco Massa <[email protected]>
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.

2 participants