Hello, where can we see the changes for the 0.5.0 ...
# kotlindl
a
Hello, where can we see the changes for the 0.5.0 alpha1 ? W'ere upgrading from KotlinDL 0.4.0. https://search.maven.org/artifact/org.jetbrains.kotlinx/kotlin-deeplearning-dataset/0.5.0-alpha-1/jar Cheers!
Also, is KotlinDL 0.5.0-alpha1 multiplatform ready?
FYI I'm mainly interested in the changes regarding the preprocessing API, we have a new use case where images are now tiff images (usually with values 0-65536) and we cannot let KotlinDL load the image since it doesn't support this image type so we'd like to load the image ourselves and pass the image data to KotlinDL for it to apply the preprocessing functions to it. Eg: We load the image into Multik array, pass that to KotlinDL and get a float array or multik array as output. (If multik integration is not there then I guess any collection would do, as long as we can pass the data from the image we loaded ourselves). Currently taking a look at https://github.com/Kotlin/kotlindl/blob/master/examples/src/main/kotlin/examples/dataset/PreprocessOnlyOneImage.kt
Also, where did the normalize preprocesing moved to ? (We used to have this in 0.4.0)
Copy code
transformTensor {
				normalize {
						mean = normalizeOptions.channelsMean.toFloatArray()
						std = normalizeOptions.channelsStd.toFloatArray()
					}
			}
j
Hi, sorry, changelog for the upcoming 0.5.0 is not done yet. All the preprocessing was moved to the
kotlin-deeplearning-impl
artifact. Yes, it is multiplatform (with the jvm and android variants).
We have preprocessing operations that use either
BufferedImage
or
Pair<FloatArray, TensorShape>
. You can use create your own
Operation
which converts you custom type to one of these types (depending of which KotlinDL operations you want to use). You can write something like this:
Copy code
val preprocessing = pipeline<CustomImageType>()
        .toFloatArray()
        .normalize {
            // std =
            // mean =
        }
    preprocessing.apply(loadImageAsCustomImageType("/path/to/image"))
(you'll have to implement
toFloatArray
and
loadImageAsCustomImageType
is your function that loads images.
a
Awesome! I will look into this, thank you so much this helps a lot
Is
preprocessing.apply(loadImageAsCustomImageType("/path/to/image"))
needed if my data is already a float array?
j
I assumed you want to apply
normalize
preprocessing to it?
apply
applies preprocessing defined above to the data.
a
Yes I want to apply
normalize
, nevermind I didnt read the method name properly, I get it ,
loadImageAsCustomImageType
is just your way of saying whatever function that returns the custom type my bad
Will try that, looks pretty straightforward from your explanation, I'll keep you posted. Thanks a lot, the new API looks pretty good btw, decoupling the loading from preprocessing is awesome
Hello @Julia Beliaeva, here is what I have so far is that correct? Any guidance is appreciated, thanks!
@Julia Beliaeva The following works but I'm wondering how to do it using Operation
j
You can either implement your own dsl function similar to
normalize
, or use
call
to call your operation, like so:
Copy code
val image: Image<Int> = //
val preprocessing = pipeline<Image<Int>>().call(ImageOperation()).normalize {
        //
}
preprocessing.apply(image)