目录
一、官方demo
1.1 开发工具
Android Studio4.1.2
pytorch1.7cpu
1.2 下载
官方:https://github.com/pytorch/android-demo-app
示例:ImageSegmentation工程
该工程下没有模型文件,需要将deeplabv3_resnet50语义分割预训练模型转换成TorchScript模型
1.3 模型转换
模型转化过程中若使用pytorch1.5及对应的torchvision版本,运行程序会报错,
因此重新安装pytorch1.7cpu及对应的torchvision
conda install pytorch==1.7.1 torchvision==0.8.2 torchaudio==0.7.2 cpuonly
import torch
# use deeplabv3_resnet50 instead of deeplabv3_resnet101 to reduce the model