简体   繁体   中英

Any idea of to solve the version problem of PyTorch model on android device? The model version must be between 3 and 5But the model version is 7

I am getting the following error while running a PyTorch model on android model?

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

Any suggestion?

following code converts the version 7 model to 5:

convert2version5 = True
if convert2version5:
    from torch.jit.mobile import (
        _backport_for_mobile,
        _get_model_bytecode_version,
    )

    MODEL_INPUT_FILE = "model_v7.ptl"
    MODEL_OUTPUT_FILE = "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))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM