Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

ios-demo-app/ ImageSegmentation failed to load model error or Thread 8: signal SGABRT #94

Open
nicspect opened this issue Nov 2, 2022 · 1 comment

Comments

@nicspect
Copy link

nicspect commented Nov 2, 2022

Hey!

I'm using the ImageSegmentation folder and following this tutorial.

LibTorch = 1.10.0
LibTorch-Lite = 1.10.0
PyTorch = 1.12.1
xcode = 14.0.1

From what I can see, the issue is simple, torch.JIT.script models do not work in my setup. I've tried both LibTorch and LibTorch-Lite. When I trace models I can trace in torch, I can load the model.

This is the line where I get all my errors:
_impl = torch::jit::load(filePath.UTF8String); or _impl = torch::jit::_load_for_mobile(filePath.UTF8String);

Any help would be great!

Nic

@cyrillkuettel
Copy link

cyrillkuettel commented Nov 28, 2022

hi @nicspect, I'm pretty sure you have to use PyTorch 11 in this particular case. Newer versions of PyTorch produce a model incompatible.

The ImageSegmentation uses Libtorch by default, but this can easily be changed, see the REAMDE.md in this directory.

Create a Pytorch 1.11 environment:

conda install jupyter pytorch==1.11.0 torchvision==0.12.0 torchaudio==0.11.0 cpuonly -c pytorch

Export the model:

import torch
print(torch.__version__)
from torch.utils.mobile_optimizer import optimize_for_mobile
model = torch.hub.load('pytorch/vision: v0.11.0', 'deeplabv3_resnet50', pretrained=True)
model.eval()
scripted_module = torch.jit.script(model)
optimized_model = optimize_for_mobile(scripted_module)
# Use this if you want to use lite interpreter. 
# optimized_model._save_for_lite_interpreter("deeplabv3_scripted.ptl")

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants