pytorch android

官方文档:

https://pytorch.org/mobile/android/

转换模型:

import torch
import torchvision
from torch.utils.mobile_optimizer import optimize_for_mobile

model = torchvision.models.mobilenet_v2(pretrained=True)
model.eval()
example = torch.rand(1, 3, 224, 224)
traced_script_module = torch.jit.trace(model, example)
traced_script_module_optimized = optimize_for_mobile(traced_script_module)
traced_script_module_optimized._save_for_lite_interpreter("app/src/main/assets/model.ptl")

有demo,有yolov5:

https://github.com/pytorch/android-demo-app

D2go

D2Go demonstrates a Python script that creates the much lighter and much faster Facebook 

你可能感兴趣的:(pytorch知识宝典)