I converted the orignal model u2net.pth to u2net.p like follows :

scripted = torch.jit.script(net)
torch.jit.save(scripted, “u2net.p”)

and also converted it to light version :

example = torch.rand(1, 3, 320, 320)
traced_script_module = torch.jit.trace(model, example)
traced_script_module_optimized = optimize_for_mobile(traced_script_module)
traced_script_module_optimized._save_for_lite_interpreter(“saved_models/u2net.ptl”)

However, I’m having some trouble using this model in android (following the instructions from here PyTorch Android 3 ), precisely in giving input and taking the output, any help would be much appreciated …