pytorch / ios-demo-app

PyTorch iOS examples
Other
599 stars 188 forks source link

Fatal error: Can't find the model file!: file #7

Closed wonbeomjang closed 4 years ago

wonbeomjang commented 4 years ago

Hello. I'm going to apply custom semantic segmentation model on IOS device. (mobilenetV2 + SegNet) But When I import the module, the problem occur.

OS: Mac OS 10.15.1 Python 3.7 Pytorch 1.3.1 Libtorch 1.3.1

Fatal error: Can't find the model file!: file /Users/aiel/Desktop/ios-demo-app/HelloWorld/HelloWorld/HelloWorld/ViewController.swift, line 11
2019-12-09 22:18:38.472617+0900 HelloWorld[37912:926691] Fatal error: Can't find the model file!: file /Users/aiel/Desktop/ios-demo-app/HelloWorld/HelloWorld/HelloWorld/ViewController.swift, line 11

I convert python model to trace model using jit, I see the file path is right by printing path in TorchModule.mm this problem occurs when I call TorchModule, ViewController.swift, line 8 and TorchModule.mm, line 18

let module = TorchModule(fileAtPath: filePath)
_impl = torch::jit::load(filePath.UTF8String);

thanks for reading

xta0 commented 4 years ago

@wonbeomjang is it OK for you to upload your project to Github or somewhere that I can get access to? such that I can debug and have a better understanding of what's going on.

wonbeomjang commented 4 years ago

I want to use this model in IOS device https://github.com/wonbeomjang/mobile-hair-segmentation-pytorch

Swift code is this https://github.com/wonbeomjang/ios-demo-app

I just modify filepath and return type of prediction TorchModule(fileAtPath: filePath) is not work in this code.

wonbeomjang commented 4 years ago

sorry, when making jit.trace model, I have to change model to eval mode, and another problem is similar to https://discuss.pytorch.org/t/model-loading-issue-in-ios/63179/2

model = model.eval() 
Joooshua commented 3 years ago

sorry, when making jit.trace model, I have to change model to eval mode, and another problem is similar to https://discuss.pytorch.org/t/model-loading-issue-in-ios/63179/2

model = model.eval() 

Hello, I am running the official demo of the Object Detection App. This error also occurred to me, and I add this line before saving the model in export.py

Still not working, any reason or solution?