flutter_pytorch_mobile icon indicating copy to clipboard operation
flutter_pytorch_mobile copied to clipboard

Error When Loading the yolov5s.pt

Open SuLi8 opened this issue 2 years ago • 3 comments
trafficstars

I replaced this line in the main.dart of the example program String pathCustomModel = "assets/models/yolov5s.pt";

After compiling and running on the IOS emulator, an error is reported: [enforce fail at inline_container.cc:222] . file not found: archive/constants.pkl

It seems that yolov5s.pt is not loaded correctly yolov5s.pt has been verified to be OK. I would like to know how to solve this problem

SuLi8 avatar Jan 01 '23 02:01 SuLi8

It could be incompatible versions. Try using pytorch 1.11 to train / export the model.

Then change this line, the iOS Libtorch version to 1.10. After that, make sure to update the dependency with cocapods:

pod update LibTorch

cyrillkuettel avatar Jan 01 '23 15:01 cyrillkuettel

Thanks but still got exceptions.

Exception raised from valid at /Users/distiller/project/caffe2/serialize/inline_container.cc:158 (most recent call first): frame #0: _ZN3c105ErrorC1ENS_14SourceLocationENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE + 75 (0x10640f933 in Runner) frame #1: _ZN3c106detail14torchCheckFailEPKcS2_jRKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEE + 106 (0x10640e535 in Runner) frame #2: ZN6caffe29serialize19PyTorchStreamReader5validEPKcS3 + 125 (0x105db516b in Runner) frame #3: _ZN6caffe29serialize19PyTorchStreamReader11getRecordIDERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE + 101 (0x105db5b75 in Runner) frame #4: _ZN6caffe29serialize19PyTorchStreamReader9getRecordERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE + 70 (0x10159e352 in Runner) frame #5: _ZN5torch3jit21readArchiveAndTensorsERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEES9_S9_N3<…> Lost connection to device.

SuLi8 avatar Jan 08 '23 00:01 SuLi8

@SuLi8 I've got the same error when importing my model, and I solved it by exporting the model as a torchscript and make sure that the model was saved for cpu and not cuda

dvagala avatar Mar 01 '23 17:03 dvagala