Yuv2tensor function seems to tortue the RGB space (mobile)

I am currently trying to deploy some realtime style-transfer model to process yuv pictures frame by frame from camera on mobile devices, and use


to convert yuv to tensor, but the RGB colorspace of the pictures generated afterwards are always tortuous. I fixed this problem by finding some other ways to convert yuv to bitmap and use


instead. It might not affect much for classification or object detection tasks, but it worths to check out if there’s really a bug in it.

Hello @Silence-Monk,
Thanks for reporting it.

There was a bug in yuv to rgb conversion, the fix was landed in master recently [android] Fix YUV camera image to tensor by IvanKobzarev · Pull Request #50871 · pytorch/pytorch · GitHub

Next nightly build of

    implementation 'org.pytorch:pytorch_android_torchvision:1.8.0-SNAPSHOT'

will contain that fix.

1 Like