当前位置:网站首页>Teach yourself to train pytorch model to Caffe (2)
Teach yourself to train pytorch model to Caffe (2)
2022-07-05 21:09:00 【FeboReigns】
The key point
Transform the training model , My model file is google_checkpoint_ep60
Reference resources :https://github.com/inisis/brocolli
https://www.bilibili.com/video/BV1fb4y177RyThe elder brother built an environment for us , So you don't have to build your own environment , But we have to download docker
Watch this video docker packed https://www.bilibili.com/video/BV11L411g7U1Then we download the image provided by brother
Concrete , At the command line, follow my brother's github Guide knock

The first line is to download the image ( It can be understood as a file in the virtual machine ), The second line is to create a container ( Create a virtual machine and boot it , And login ), I recommend that you put --rm Went to the , Otherwise cmd After exiting, the container is automatically deleted , The third line is to enter the container and execute the command
This command is to transform the model , Last saved in tmp In the folder .

If there is no error, let's start to convert our own model
I use docker cp Copy between host and container
First of all, put our cats and dogs GoogLeNet.py Copy in .
docker cp E:/workspace/brocolli/custom_models/GoogLeNet.py ee132b3c68f8b98f204de3bbb8872573e9fb00db319a3dd8bb2c3674f6d4a776:/root/brocolli/custom_models The front is the host file or folder , Behind it is the container id ,id It can be downloaded from docker desktop Copy


Finally, the container folder
Then we write a script to transform our model , Brother readme plagiarism/copycat

My file is called run.py
import torchvision
import torch
from custom_models import GoogLeNet
model = GoogLeNet.GoogLeNet(num_classes=2) # Here, you should use your ownd model
model.load_state_dict(torch.load("./google_checkpoint_ep60.pth",map_location=torch.device('cpu')),)
# input = torch.rand(1,3,224,224)
# output = model(input)
# aaa = 100
from bin.pytorch2caffe import Runner # if caffe, use bin.pytorch2caffe, if TensorRT use bin.pytorch2trt;
runner = Runner("googlenet_dog", model, [1, 3, 224, 224], 13,True)
runner.pyotrch_inference()
runner.convert()
runner.caffe_inference() # if caffe, use caffe_inference, if TensorRT use trt_inference;
runner.check_result()We put run.py and google_checkpoint_ep60.pth Use both docker cp Copied to the /root/brocolli in
And then run , Conversion completed , hold tmp Below googlenet_dog.prototxt and googlenet_dog.caffemodel Copy is over
Split line ---------------------------------
docker Some orders
docker run Create a container
docker run -it yaphets4desmond/brocolli:v1.0 bashIf you used rm Deleted , Use the above command to create a , Or so

If you handle it carefully bash The window is closed , But he is still running

You can use the command to enter bash, The long one is the container id
docker exec -it e132bd2faff7adb3596068d0f53316fc54d20309f2aed6464984206f3a811fe4 bash 边栏推荐
- postgis 安装地理信息扩展
- What are the requirements of UL 2043 test for drive housing in the United States?
- Viewrootimpl and windowmanagerservice notes
- 实现浏览页面时校验用户是否已经完成登录的功能
- Hdu2377bus pass (build more complex diagram +spfa)
- shell编程100例
- 第05章_存储引擎
- Introduction of ArcGIS grid resampling method
- 当用户登录,经常会有实时的下拉框,例如,输入邮箱,将会@qq.com,@163.com,@sohu.com
- Deep merge object deep copy of vant source code parsing
猜你喜欢

Arcgis\qgis no plug-in loading (no offset) mapbox HD image map

LeetCode_哈希表_困难_149. 直线上最多的点数

Enclosed please find. Net Maui's latest learning resources

EN 438-7建筑覆盖物装饰用层压板材产品—CE认证

ArcGIS栅格重采样方法介绍
![R language [data management]](/img/41/b89bb8794c06280e58988e1c1a5e02.png)
R language [data management]

面试官:并发编程实战会吗?(线程控制操作详解)

显示屏DIN 4102-1 Class B1防火测试要求

Clion configures Visual Studio (MSVC) and JOM multi-core compilation

Which is the best online collaboration product? Microsoft loop, notion, flowus
随机推荐
基于flask写一个接口
Display DIN 4102-1 Class B1 fire test requirements
水泥胶黏剂BS 476-4 不燃性测试
Sequence alignment
MySQL 千万数据量深分页优化, 拒绝线上故障!
Longest swing sequence [greedy practice]
vant 源码解析 之深层 合并对象 深拷贝
Web Service简单入门示例
Clickhouse copy paste multi line SQL statement error
What are the requirements of UL 2043 test for drive housing in the United States?
当用户登录,经常会有实时的下拉框,例如,输入邮箱,将会@qq.com,@163.com,@sohu.com
Clion-MinGW编译后的exe文件添加ico图标
EasyExcel的读写操作
leetcode:1755. Sum of subsequences closest to the target value
selenium 获取dom内验证码图片
Simple getting started example of Web Service
Aitm 2-0003 horizontal combustion test
Clion configures Visual Studio (MSVC) and JOM multi-core compilation
实现浏览页面时校验用户是否已经完成登录的功能
hdu2377Bus Pass(构建更复杂的图+spfa)