Hello, what would you guys recommend to use for im...
# ai
a
Hello, what would you guys recommend to use for image pre-processing on Kotlin ? (Equivalent to what PIL offers) I'm looking for something simple that can do what PIL did for me on Python when it came to loading raw images bytes into (m,C,H,W) matrix. If possible I'd prefer a library that is lightweight, I just need to do preprocessing of raw bytes into rgb matrix and maybe basic normalization if possible. But if there is no library just for that then I'll take whatever works. Should I try D4J or OpenCV Java or is there a better Kotlin alternative? Thanks
z
Could you share please the list of required preprocessing ops or the whole Python code?
At this moment opencv is the best option, but it's opencv
a
@zaleslaw Sure, nothing crazy, Normalization (mean,std),ByteArray to RGB N-array, reshape. PS: I can't wait for Kotlin to overtake the data science world.
K 1
I can send you code snippets when I get home
z
Yes, it will be great
a
@zaleslaw Something like this but in Kotlin (one screenshot uses PyTorch, the other one does almost the same thing but in Numpy instead) PS: The normalize values are just fillers for the purpose of the discussion, we might not always want grayscale.
z
What torch transforms do you usually use? I see to tensor/normalize. Do you use any resize method or methods for noise removing?
Maybe something else?
What np operations do you use? (I see reshape) what about transpose?
a
Yes resizing transforms, horizontal flip are other transforms that we could use
👍 1
We are trying to see if we can do the preprocessing/postprocessing in kotlin and keep the model in python or if we must do the pre-processing in python as well. I will explore OpenCV Java, if you have a better alternative let me know.
z
It's actual question for me too, of course I share if found something better or image preprocessing dsl in KotlinDL will cover more basic use cases
👍 1
a
@zaleslaw Does KotlinDL have those preprocessing mentioned above ? Load image into tensor, reshape tensor, resize, normalize ? If not what do you use ?
It will be extended in the 0.3, we are planned to add a few transformation from torchvision to support preprocessing (and postprocessing) for ONNX models for Image Recognition, Object Detection, Face Alignment and so on
👍 1