当前位置:网站首页>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/BV1fb4y177Ry
The 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/BV11L411g7U1
Then 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 bash
If 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
边栏推荐
- Comparison table of foreign lead American abbreviations
- Learning robots have no way to start? Let me show you the current hot research directions of robots
- int GetMonth( ) const throw( ); What does throw () mean?
- Who the final say whether the product is good or not? Sonar puts forward performance indicators for analysis to help you easily judge product performance and performance
- PVC plastic sheets BS 476-6 determination of flame propagation properties
- Opérations de lecture et d'écriture pour easyexcel
- Golang(1)|从环境准备到快速上手
- WPF gets the control in the datagridtemplatecolumn of the specified row and column in the DataGrid
- js常用方法封装
- Golang (1) | from environmental preparation to quick start
猜你喜欢
Reading and writing operations of easyexcel
ArcGIS\QGIS无插件加载(无偏移)MapBox高清影像图
Research and development efficiency improvement practice of large insurance groups with 10000 + code base and 3000 + R & D personnel
最长摆动序列[贪心练习]
示波器探头对信号源阻抗的影响
leetcode:1755. 最接近目标值的子序列和
Clickhouse copy paste multi line SQL statement error
How to send samples when applying for BS 476-7 display? Is it the same as the display??
LeetCode_哈希表_困难_149. 直线上最多的点数
显示屏DIN 4102-1 Class B1防火测试要求
随机推荐
秋招将临 如何准备算法面试、回答算法面试题
Binary search
postgres 建立连接并删除记录
vant 源码解析 之深层 合并对象 深拷贝
Using webassembly to operate excel on the browser side
Establishment of terminal security capability verification environment and penetration test records
MYSQL IFNULL使用功能
EasyExcel的讀寫操作
Test of incombustibility of cement adhesives BS 476-4
shell编程100例
浅聊我和一些编程语言的缘分
Generics of TS
Introduction of ArcGIS grid resampling method
100 cases of shell programming
vant 源码解析之 utils/index.ts 工具函数
基于flask写一个接口
MySQL 千万数据量深分页优化, 拒绝线上故障!
Learning robots have no way to start? Let me show you the current hot research directions of robots
基于vertx-web-sstore-redis的改造实现vertx http应用的分布式session
Why can't Chinese software companies produce products? Abandon the Internet after 00; Open source high-performance API gateway component of station B | weekly email exclusive to VIP members of Menon w