Converting DataLoader and transform code to Android for SuperSlowMo

I’m currently making a (private) fork of this implementation of NVIDIA’s SuperSlowMo to adapt it to Android, for a university project. In short, it increases the frames in a video. In it’s main you can see that, after converting the input video to png frames, it transforms and loads them with this block of code:

    mean = [0.429, 0.431, 0.397]
    std  = [1, 1, 1]
    normalize = transforms.Normalize(mean=mean, std=std)
    negmean = [x * -1 for x in mean]
    revNormalize = transforms.Normalize(mean=negmean, std=std)

    if (device == "cpu"):
        transform = transforms.Compose([transforms.ToTensor()])
        TP = transforms.Compose([transforms.ToPILImage()])

        transform = transforms.Compose([transforms.ToTensor(), normalize])
        TP = transforms.Compose([revNormalize, transforms.ToPILImage()])

    # Load data

    videoFrames = dataloader.Video(root=extractionPath, transform=transform)
    videoFramesloader =, batch_size=args.batch_size, shuffle=False)

Of course, the Pytorch Android API is lightweight, and it doesn’t look like it has either something analogous to the dataloader or the transform modules. I’m a bit lost in how I could adapt that to Java for making the app, though.

PyTorch Android API is just a JNI wrapper on top of PyTorch C++ API. You may need to write a JNI wrapper to call the underlying C++ API (if exists) of that library, or just do it in Android native (C++) library.