-
Notifications
You must be signed in to change notification settings - Fork 106
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
Refactor ImageConvertor and add Convert and Grayscale preprocessors #256
Merged
+472
−326
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@juliabeliaeva On first review it looks well, could you please merge the master into this branch and I'll start the final review and play with the new DSL in the sandbox, I want to test on different images |
When image data is not stored in bytes, use method getPixels to retrieve floats. Since this method always returns channels in the rgb order, swap channels when bgr order is required.
Null value will mean that the number of channels is not known.
fb59e80
to
3a186fc
Compare
@zaleslaw rebased on master to avoid extra merge commits. |
3a186fc
to
05f0635
Compare
No objection from my side regarding this PR, very highly qualified work |
michalharakal
pushed a commit
to michalharakal/KotlinDL
that referenced
this pull request
Nov 30, 2021
…otlin#256) * Convert ImageConverter from class to object * Remove unused parameter * Reorganize methods in ImageConverter * Cleanup imageToByteArray * Support more image types in ImageConverter When image data is not stored in bytes, use method getPixels to retrieve floats. Since this method always returns channels in the rgb order, swap channels when bgr order is required. * Add tests for ImageConverter * Add Convert preprocessor * Remove unused function * Replace colorMode field from Loading operation with Convert preprocessor * Rename ColorOrder to ColorMode * Support grayscale images * Add Grayscale image preprocessor * Allow for ImageShape#channels to be nullable Null value will mean that the number of channels is not known. * Keep original image type in image preprocessors * Remove outdated comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR has the following changes:
ImageConvertor
to support more image types (TYPE_3BYTE_BGR
,TYPE_INT_BGR
,TYPE_INT_RGB
,TYPE_BYTE_GRAY
are tested, but the code should work for other types).Loading#colorMode
with a separate preprocessorConvert
to convert the image to the desired type.colorMode
was used only for transformingBufferredImage
intoFloatArray
and does not seem to belong toLoading
operation. After this refactoring image is transformed to floats "as is" and conversions are performed during image preprocessing stage. This change will also simplifyLoading
operation refactoring necessary for [Preprocessing] Split the Load preprocessing stage into two parts: LoadFile and LoadDir #227.ImageShape#channels
is made nullable. This will allow to define image shape when the number of channels is not known and to keep the same number of channels as in the original image in preprocessors such asresize
.ColorOrder
is renamed toColorMode
and now represents a more generic "image type".grayscale
preprocessor is added as aConvert
operation withColorMode.GRAYSCALE
target. Fixes Add Grayscale image preprocessor #202.