-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Stb #3823
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
Stb #3823
Conversation
Signed-off-by: Omar Shrit <[email protected]>
Signed-off-by: Omar Shrit <[email protected]>
Signed-off-by: Omar Shrit <[email protected]>
|
It could also be a good idea to update STB is dual-licensed... both under the MIT and also it's in the public domain (which means we wouldn't have to list it in the license). But I think it might be a good idea to point it out in the license file, both to give credit to the STB authors and also so that people coming through the project have more ways to learn that we are bundling STB. |
Signed-off-by: Omar Shrit <[email protected]>
Signed-off-by: Omar Shrit <[email protected]>
Signed-off-by: Omar Shrit <[email protected]>
rcurtin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, it will be super useful to add some extra image support. My main comment is that we should use the same formats for images that data::Load gives.
Also, up to you, but do you want to separate this into two separate PRs for simplicity? One could be including STB as part of mlpack and making those CMake configuration changes, and the other one could be the resize/crop functionality that you added in the latest commit.
Signed-off-by: Omar Shrit <[email protected]>
Signed-off-by: Omar Shrit <[email protected]>
Signed-off-by: Omar Shrit <[email protected]>
Signed-off-by: Omar Shrit <[email protected]>
Signed-off-by: Omar Shrit <[email protected]>
Signed-off-by: Omar Shrit <[email protected]>
Signed-off-by: Omar Shrit <[email protected]>
Signed-off-by: Omar Shrit <[email protected]>
Signed-off-by: Omar Shrit <[email protected]>
Signed-off-by: Omar Shrit <[email protected]>
rcurtin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments on the STB CMake code---hopefully it's helpful. I'm looking forward to having STB bundled; it'll make life easier 😄
Co-authored-by: Ryan Curtin <[email protected]>
Co-authored-by: Ryan Curtin <[email protected]>
Co-authored-by: Ryan Curtin <[email protected]>
Signed-off-by: Omar Shrit <[email protected]>
Co-authored-by: Ryan Curtin <[email protected]>
Co-authored-by: Ryan Curtin <[email protected]>
Co-authored-by: Ryan Curtin <[email protected]>
Co-authored-by: Ryan Curtin <[email protected]>
Co-authored-by: Ryan Curtin <[email protected]>
Co-authored-by: Ryan Curtin <[email protected]>
Signed-off-by: Omar Shrit <[email protected]>
Signed-off-by: Omar Shrit <[email protected]>
Signed-off-by: Omar Shrit <[email protected]>
Signed-off-by: Omar Shrit <[email protected]>
Signed-off-by: Omar Shrit <[email protected]>
|
@mlpack-jenkins test this please |
1 similar comment
|
@mlpack-jenkins test this please |
Signed-off-by: Omar Shrit <[email protected]>
Signed-off-by: Omar Shrit <[email protected]>
|
@mlpack-jenkins test this please |
rcurtin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks good to me. There is a bug with the conv_to in the image resize functionality (take a look, I think I have the fix in the comments), and there are a few simple optimizations I think we can make. It's late now so I won't try it, but I will do it tomorrow when I get up unless you get to it first (I think all my suggested fixes should work directly, take a look and let me know what you think). Glad to get this merged, sorry I have had so many tedious comments throughout 😄
| arma::fmat tempDestFloat(newDimension, 1); | ||
| stbir_resize_float_linear(images.colptr(i), info.Width(), info.Height(), | ||
| 0, tempDestFloat.memptr(), newWidth, newHeight, 0, channels); | ||
| resizedFloatImages.col(i) = std::move(tempDestFloat); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| arma::fmat tempDestFloat(newDimension, 1); | |
| stbir_resize_float_linear(images.colptr(i), info.Width(), info.Height(), | |
| 0, tempDestFloat.memptr(), newWidth, newHeight, 0, channels); | |
| resizedFloatImages.col(i) = std::move(tempDestFloat); | |
| stbir_resize_float_linear(images.colptr(i), info.Width(), info.Height(), | |
| 0, resizedFloatImages.colptr(i), newWidth, newHeight, 0, channels); |
| arma::Mat<unsigned char> tempDest(newDimension, 1); | ||
| stbir_resize_uint8_linear(images.colptr(i), info.Width(), info.Height(), | ||
| 0, tempDest.memptr(), newWidth, newHeight, 0, channels); | ||
|
|
||
| resizedImages.col(i) = std::move(tempDest); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| arma::Mat<unsigned char> tempDest(newDimension, 1); | |
| stbir_resize_uint8_linear(images.colptr(i), info.Width(), info.Height(), | |
| 0, tempDest.memptr(), newWidth, newHeight, 0, channels); | |
| resizedImages.col(i) = std::move(tempDest); | |
| stbir_resize_uint8_linear(images.colptr(i), info.Width(), info.Height(), | |
| 0, resizedImages.colptr(i), newWidth, newHeight, 0, channels); |
I am pretty sure that this should work. I will try it locally tomorrow, but you will wake up earlier than me so if you want you can try it too 😄
| } | ||
| } | ||
|
|
||
| images = std::move(resizedImages); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| images = std::move(resizedImages); | |
| images = arma::conv_to<Mat<eT>>::from(std::move(resizedImages)); |
We need to put the conv_to here, because resizedImages has type arma::Mat<unsigned char> and images has type arma::Mat<eT>.
| arma::Mat<unsigned char> tempDest(newDimension, 1); | ||
|
|
||
| stbir_resize_uint8_linear(tempSrc.colptr(i), info.Width(), info.Height(), | ||
| 0, tempDest.memptr(), newWidth, newHeight, 0, channels); | ||
|
|
||
| resizedImages.col(i) = arma::conv_to<arma::Mat<eT>>::from(tempDest); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| arma::Mat<unsigned char> tempDest(newDimension, 1); | |
| stbir_resize_uint8_linear(tempSrc.colptr(i), info.Width(), info.Height(), | |
| 0, tempDest.memptr(), newWidth, newHeight, 0, channels); | |
| resizedImages.col(i) = arma::conv_to<arma::Mat<eT>>::from(tempDest); | |
| stbir_resize_uint8_linear(tempSrc.colptr(i), info.Width(), info.Height(), | |
| 0, resizedImages.colptr(i), newWidth, newHeight, 0, channels); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Second approval provided automatically after 24 hours. 👍
Co-authored-by: Ryan Curtin <[email protected]>
Co-authored-by: Ryan Curtin <[email protected]>
Make STB part of mlpack.
Just a draft, to get an idea if this works with the CI