I'm trying to migrate deep learning process in python and now need to convert it into kotlin (android studio) but struglling with this part for few days :(
can someone help me to convert python code to kotlin?
The type of out is Tensor.
IMAGE_SIZE is 350 and half is 175.
out = torch.argmax(out, dim=1, keepdims=True).permute(0, 2, 3, 1)[0].numpy().squeeze().astype(np.int32)
r_H, r_W = out.shape
_out_extended = np.zeros((IMAGE_SIZE + r_H, IMAGE_SIZE + r_W), dtype=out.dtype)
_out_extended[half : half + IMAGE_SIZE, half : half + IMAGE_SIZE] = out * 255
out = _out_extended.copy()
I also tried to use argmax function from Multik library but the input type is not the same. (not Tensor, but MultiArray).
Any other suggestion for migration from python to kotlin would be welcomed!
I kinda figured it out by myself.
In kotlin, I was not able to use argmax function so had to convert it somehow.
'outputs' are equivalent to the 'out' from my question.
And for the _out_extended part, after I convert the intVal to mat (= originalImage), I used this method in order to extend the output.