当前位置:网站首页>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 边栏推荐
- AITM 2-0003 水平燃烧试验
- selenium 获取dom内属性值的方法
- [case] Application of element display and hiding -- element mask
- Binary search
- R语言【数据管理】
- leetcode:1139. The largest square bounded by 1
- Write an interface based on flask
- 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
- @Validated basic parameter verification, grouping parameter verification and nested parameter verification
- Simple getting started example of Web Service
猜你喜欢

Écrire une interface basée sur flask

EN 438-7建筑覆盖物装饰用层压板材产品—CE认证
![R language [data management]](/img/41/b89bb8794c06280e58988e1c1a5e02.png)
R language [data management]

从架构上详解技术(SLB,Redis,Mysql,Kafka,Clickhouse)的各类热点问题

Realize the function of verifying whether the user has completed login when browsing the page

【案例】定位的运用-淘宝轮播图

Mathematical analysis_ Notes_ Chapter 9: curve integral and surface integral

五层网络协议

Write an interface based on flask

Five layer network protocol
随机推荐
Mathematical analysis_ Notes_ Chapter 9: curve integral and surface integral
Five layer network protocol
Influence of oscilloscope probe on measurement bandwidth
SQL series (basic) - Chapter 2 limiting and sorting data
Explain various hot issues of Technology (SLB, redis, mysql, Kafka, Clickhouse) in detail from the architecture
基于vertx-web-sstore-redis的改造实现vertx http应用的分布式session
100 cases of shell programming
php中explode函数存在的陷阱
JS common method encapsulation
模式-“里氏替换原则”
The reason why the ncnn converted model on raspberry pie 4B always crashes when called
面试官:并发编程实战会吗?(线程控制操作详解)
Longest swing sequence [greedy practice]
leetcode:1139. 最大的以 1 为边界的正方形
请查收.NET MAUI 的最新学习资源
MYSQL IFNULL使用功能
Binary search
CLion配置visual studio(msvc)和JOM多核编译
Viewrootimpl and windowmanagerservice notes
selenium 获取dom内验证码图片