Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Rename Serializer to Output and move to flash.core.data.io.output #927

Merged
merged 22 commits into from
Nov 5, 2021

Conversation

ethanwharris
Copy link
Collaborator

@ethanwharris ethanwharris commented Nov 3, 2021

What does this PR do?

Fixes #917

Before submitting

  • Was this discussed/approved via a Github issue? (no need for typos and docs improvements)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure your PR does only one thing, instead of bundling different changes together?
  • Did you make sure to update the documentation with your changes?
  • Did you write any new necessary tests? [not needed for typos/docs]
  • Did you verify new and existing tests pass locally with your changes?
  • If you made a notable change (that affects users), did you update the CHANGELOG?

PR review

  • Is this pull request ready for review? (if not, please submit in draft mode)

Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.

Did you have fun?

Make sure you had fun coding 🙃

@ethanwharris ethanwharris changed the title Rename Serializer to Output and move to flash.core.data.io.output [WIP] Rename Serializer to Output and move to flash.core.data.io.output Nov 3, 2021
@codecov
Copy link

codecov bot commented Nov 3, 2021

Codecov Report

Merging #927 (11d4480) into master (6ce7d68) will decrease coverage by 12.30%.
The diff coverage is 94.30%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master     #927       +/-   ##
===========================================
- Coverage   88.33%   76.02%   -12.31%     
===========================================
  Files         241      242        +1     
  Lines       13017    13053       +36     
===========================================
- Hits        11498     9924     -1574     
- Misses       1519     3129     +1610     
Flag Coverage Δ
unittests 76.02% <94.30%> (-12.31%) ⬇️

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

Impacted Files Coverage Δ
flash/core/integrations/fiftyone/utils.py 37.93% <ø> (ø)
flash/core/serve/types/image.py 94.44% <ø> (ø)
flash/core/data/process.py 82.23% <73.33%> (-5.54%) ⬇️
flash/core/data/batch.py 95.18% <75.00%> (-0.75%) ⬇️
flash/image/detection/output.py 28.57% <75.00%> (ø)
flash/image/segmentation/output.py 76.47% <80.00%> (ø)
flash/core/model.py 86.15% <93.75%> (-1.91%) ⬇️
flash/__init__.py 90.90% <100.00%> (+0.43%) ⬆️
flash/audio/speech_recognition/model.py 100.00% <100.00%> (ø)
flash/core/classification.py 59.74% <100.00%> (-34.42%) ⬇️
... and 104 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 6ce7d68...11d4480. Read the comment docs.

@ethanwharris ethanwharris changed the title [WIP] Rename Serializer to Output and move to flash.core.data.io.output Rename Serializer to Output and move to flash.core.data.io.output Nov 3, 2021
docs/source/general/predictions.rst Outdated Show resolved Hide resolved
docs/source/template/optional.rst Outdated Show resolved Hide resolved
flash/core/model.py Outdated Show resolved Hide resolved
flash/core/model.py Outdated Show resolved Hide resolved
@@ -67,7 +67,7 @@ def __init__(
metrics=metrics,
learning_rate=learning_rate,
multi_label=multi_label,
serializer=serializer or Labels(),
output=output or Labels(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Personal preference, but I would prefer LabelsOutput as we would have InputImagePaths. This would make it more consistent and readable too.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think we should leave that for a potential follow up as we would need to deprecate Labels etc. rather than just rename as they are a public API.

@mergify mergify bot added the has conflicts label Nov 4, 2021
@mergify mergify bot removed the has conflicts label Nov 4, 2021
@@ -90,7 +90,7 @@ def _visualize(self, labels):
plt.imshow(labels_vis)
plt.show()

def serialize(self, sample: Dict[str, torch.Tensor]) -> torch.Tensor:
def transform(self, sample: Dict[str, torch.Tensor]) -> torch.Tensor:
Copy link
Contributor

Choose a reason for hiding this comment

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

@ethanwharris do you think this adds confusion, naming serialize to transform, since we have transform being used at other places.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Maybe, although it definitely shouldn't be called serialize any more. As the role of Output is to convert raw predictions into the desired output format I think transform is fine. But it could otherwise be something more explicit like convert(raw_predictions) rather than transform(sample)

Copy link
Contributor

Choose a reason for hiding this comment

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

I was thinking about export_transform.

Copy link
Contributor

@tchaton tchaton left a comment

Choose a reason for hiding this comment

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

LGTM !

# 3. Attach the Serializer
model.serializer = Probabilities()
# 3. Attach the Output
model.output = Probabilities()
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we call them ProbabilitiesOutput ?

@ethanwharris ethanwharris merged commit d1be93c into master Nov 5, 2021
@ethanwharris ethanwharris deleted the feature/rename_serializer branch November 5, 2021 17:33
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rename Serializer to Output
3 participants