pytorch / android-demo-app

PyTorch android examples of usage in applications
1.46k stars 604 forks source link

Lite Interpreter verson number does not match. The model version must be between 3 and 5But the model version is 7 #217

Closed yemreeee closed 2 years ago

yemreeee commented 2 years ago

How do i resolve this? Every pytorch example (Especially android) that i tried, i have same problem. Thanks for your comments in advance.

yemreeee commented 2 years ago

I forget the gradle version of pytorch lite. Set 'org.pytorch:pytorch_android_lite:1.9.0' to 1.10.0.

celikmustafa89 commented 2 years ago
convert2version5 = True
if convert2version5:
    from torch.jit.mobile import (
        _backport_for_mobile,
        _get_model_bytecode_version,
    )

    MODEL_INPUT_FILE = "type2_model_v7.ptl"
    MODEL_OUTPUT_FILE = "type2_model_v5.ptl"

    print("model version", _get_model_bytecode_version(f_input=MODEL_INPUT_FILE))

    _backport_for_mobile(f_input=MODEL_INPUT_FILE, f_output=MODEL_OUTPUT_FILE, to_version=5)

    print("new model version", _get_model_bytecode_version(MODEL_OUTPUT_FILE))