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

[Data] Add Dataset.write_images #38228

Merged
merged 11 commits into from
Aug 9, 2023
Merged

[Data] Add Dataset.write_images #38228

merged 11 commits into from
Aug 9, 2023

Conversation

bveeramani
Copy link
Member

Why are these changes needed?

Users want to write images back to S3 (for example, segmentation masks from batch inference). So, this PR adds a Dataset.write_images API.

Related issue number

Checks

  • I've signed off every commit(by using the -s flag, i.e., git commit -s) in this PR.
  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
    • I've added any new APIs to the API Reference. For example, if I added a
      method in Tune, I've added it in doc/source/tune/api/ under the
      corresponding .rst file.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

Signed-off-by: Balaji Veeramani <balaji@anyscale.com>
Signed-off-by: Balaji Veeramani <balaji@anyscale.com>
@bveeramani bveeramani changed the title [Data] Add support for writing images [Data] Add Dataset.write_images` Aug 8, 2023
@bveeramani bveeramani changed the title [Data] Add Dataset.write_images` [Data] Add Dataset.write_images Aug 8, 2023
@amogkam
Copy link
Contributor

amogkam commented Aug 8, 2023

Let's tag this as an alpha API and make the necessary changes to the documentation (API reference, working with images)?

Signed-off-by: Balaji Veeramani <balaji@anyscale.com>
python/ray/data/dataset.py Outdated Show resolved Hide resolved
python/ray/data/dataset.py Outdated Show resolved Hide resolved
python/ray/data/datasource/file_based_datasource.py Outdated Show resolved Hide resolved
Signed-off-by: Balaji Veeramani <balaji@anyscale.com>
…o write-images

Signed-off-by: Balaji Veeramani <balaji@anyscale.com>
Signed-off-by: Balaji Veeramani <balaji@anyscale.com>
Signed-off-by: Balaji Veeramani <balaji@anyscale.com>
Signed-off-by: Balaji Veeramani <balaji@anyscale.com>
Signed-off-by: Balaji Veeramani <balaji@anyscale.com>
Signed-off-by: Balaji Veeramani <balaji@anyscale.com>
@bveeramani bveeramani added the tests-ok The tagger certifies test failures are unrelated and assumes personal liability. label Aug 9, 2023
@bveeramani
Copy link
Member Author

Failing code format is unrelated:



dashboard/modules/reporter/reporter_head.py:42:89: E501 line too long (91 > 88 characters)
--
  | dashboard/modules/reporter/reporter_head.py:188:89: E501 line too long (95 > 88 characters)
  | dashboard/modules/reporter/reporter_head.py:191:30: F541 f-string is missing placeholders


@bveeramani bveeramani merged commit 273a2a1 into master Aug 9, 2023
59 of 63 checks passed
@bveeramani bveeramani deleted the write-images branch August 9, 2023 02:17
def write_images(
self,
path: str,
column: str,
Copy link
Contributor

Choose a reason for hiding this comment

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

why we require users to set column by default? Should this be optional? By default we should assume the dataset should only have one column, and users want to write it as an image, right?


image = Image.fromarray(row[column])
buffer = io.BytesIO()
image.save(buffer, format=file_format)
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the error message looks like if user provides an illegal file format?

@pytest.mark.parametrize("file_format", [None, "png"])
def test_write_images(ray_start_regular_shared, file_format, tmp_path):
ds = ray.data.read_images("example://image-datasets/simple")
ds.write_images(
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we also test followed cases:

  • the dataset has multiple columns
  • the provided file format is illegal
  • write_images(), then read_images() back.

path: The path to the destination root directory, where
the images are written to.
column: The column containing the data you want to write to images.
file_format: The image file format to write with. For available options,
Copy link
Contributor

Choose a reason for hiding this comment

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

it's good we provide a link here, let's do one more step further, just to give users a list of common file formats, so they don't need to read the other documentation:

Examples of popular file formats are "png", "jpg", "jpeg", "tif", "tiff", "bmp", "gif". By default write in "png" format.

bveeramani added a commit that referenced this pull request Aug 9, 2023
#37043, #37874, and #38228 broke the code-format lint. This PR fixes it.
NripeshN pushed a commit to NripeshN/ray that referenced this pull request Aug 15, 2023
Users want to write images back to S3 (for example, segmentation masks from batch inference). So, this PR adds a Dataset.write_images API.

Signed-off-by: NripeshN <nn2012@hw.ac.uk>
NripeshN pushed a commit to NripeshN/ray that referenced this pull request Aug 15, 2023
ray-project#37043, ray-project#37874, and ray-project#38228 broke the code-format lint. This PR fixes it.

Signed-off-by: NripeshN <nn2012@hw.ac.uk>
harborn pushed a commit to harborn/ray that referenced this pull request Aug 17, 2023
Users want to write images back to S3 (for example, segmentation masks from batch inference). So, this PR adds a Dataset.write_images API.

Signed-off-by: harborn <gangsheng.wu@intel.com>
harborn pushed a commit to harborn/ray that referenced this pull request Aug 17, 2023
ray-project#37043, ray-project#37874, and ray-project#38228 broke the code-format lint. This PR fixes it.

Signed-off-by: harborn <gangsheng.wu@intel.com>
harborn pushed a commit to harborn/ray that referenced this pull request Aug 17, 2023
Users want to write images back to S3 (for example, segmentation masks from batch inference). So, this PR adds a Dataset.write_images API.
harborn pushed a commit to harborn/ray that referenced this pull request Aug 17, 2023
arvind-chandra pushed a commit to lmco/ray that referenced this pull request Aug 31, 2023
Users want to write images back to S3 (for example, segmentation masks from batch inference). So, this PR adds a Dataset.write_images API.

Signed-off-by: e428265 <arvind.chandramouli@lmco.com>
arvind-chandra pushed a commit to lmco/ray that referenced this pull request Aug 31, 2023
ray-project#37043, ray-project#37874, and ray-project#38228 broke the code-format lint. This PR fixes it.

Signed-off-by: e428265 <arvind.chandramouli@lmco.com>
vymao pushed a commit to vymao/ray that referenced this pull request Oct 11, 2023
Users want to write images back to S3 (for example, segmentation masks from batch inference). So, this PR adds a Dataset.write_images API.

Signed-off-by: Victor <vctr.y.m@example.com>
vymao pushed a commit to vymao/ray that referenced this pull request Oct 11, 2023
ray-project#37043, ray-project#37874, and ray-project#38228 broke the code-format lint. This PR fixes it.

Signed-off-by: Victor <vctr.y.m@example.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests-ok The tagger certifies test failures are unrelated and assumes personal liability.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants