pytorch / android-demo-app

PyTorch android examples of usage in applications
1.47k stars 606 forks source link

Deeplabv3 segmentation models shape is still [1,21,320,480] although expected [1,1,320,480] #174

Open adnankarim opened 3 years ago

adnankarim commented 3 years ago

Deeplabv3 segmentation models output shape is still [1,21,320,480] although expected [1,1,320,480] moreover, can't seem to find the way to process the output in java like the given python code below. Capture

Here I am using the code of

(msminhas93/DeepLabv3FineTuning) from github for binary segmentation of crackforest dataset.

It uses the threshold post processing of the model’s output to get segmentation output to be displayed else we are getting blank single color output (same output is displaying when this model’s .ptl file deployed in example android deeplabv3 segmentation code)

“You can see the inference for binary segmentation notebook below in python”

Url: DeepLabv3FineTuning/Analysis.ipynb at master · msminhas93/DeepLabv3FineTuning (github.com)

I have limited knowledge of java, thus what changes I should make to the given android java code to display the image segmented output image as done in python in above code. image

android-demo-app/MainActivity.java at master · pytorch/android-demo-app (github.com)

as you can see I am getting predicted pytorch tensor in java, how to apply same post processing steps to this tensor as done in analysis notebook shared above.