当前位置:网站首页>Openvino2022 dev tools installation and use
Openvino2022 dev tools installation and use
2022-06-24 20:17:00 【Opencv school】
Click on the blue words above to follow us
WeChat official account :OpenCV School Focus on getting more computer vision and deep learning knowledge
introduction
OpenVINO2022 After the release , Make a clear division of the functions of previous versions , Which still passes exe The way to install the program is runtime Inference package , Support ONNX、IR、PADDLE Wait for model reading and reasoning . But model optimization transformation 、 Other functions, such as the model library download function, are divided into one called Dev Tool Part of . This part can be passed through pip Way to install directly , Then direct the line through the command line , Complete the model transformation , Download and other operations , Compared with previous versions, the usability has been greatly improved ! Make a comparison as follows :
Dev Tools Installation and use
Dev Tools Easy to install , You can choose to install directly through the command line of the official script , The only thing to note is the choice of model framework support , I chose ONNX/Pytorch Format conversion support , The installed command line is as follows :
pip install openvino-dev[onnx,pytorch]==2022.1.0After executing this command line, the installation is completed , As long as the network is not connected, the installation can be successful !
installation is complete , Change one ONNX The format model is IR Format (xml/bin) file , With Pytorch Of ResNet18 For example , First convert to ONNX, The code is as follows :
model = models.resnet18(pretrained=True) model.eval() model.cpu()
dummy_input1 = torch.randn(1, 3, 224, 224) torch.onnx.export(model, (dummy_input1), "resnet_model.onnx", verbose=True)Then run the command line directly to convert IR Format file , The screenshot is as follows :
Model download
installation is complete Dev Tools after , Download model , Just execute the command line : Examples are as follows :
omz_downloader --name person-detection-0200Means downloading the model person-detection-0200 It is a lightweight face detection model .
omz_downloader Supported parameters :
--all Means to download all models , Don't do this !--name Download one or more models with the specified names , Recommended !--precisions Represents the downloaded model accuracy parameters , Support FP32/FP18/INT8Python SDK Use
Before comparison Python Version of SDK, It works a lot , The most obvious feeling is that there is no need to read input and output , Then a bunch of settings , For a single I / O network , The call is especially simple and convenient ! It's easier for developers to get started ! I have successfully converted one above pytorch The image classification model is IR Format , You can use it now , be based on OpenVINO2022 The latest version Python SDK Deployment call , The implementation code is as follows :
# Load tag data
with open('imagenet_classes.txt') as f:
labels = [line.strip() for line in f.readlines()]
def resnet_demo():
ie = Core()
# model = ie.read_model(model="resnet_model.onnx")
model = ie.read_model(model="resnet_model.xml")
compiled_model = ie.compile_model(model=model, device_name="CPU")
output_layer = compiled_model.output(0)
means = np.zeros((224, 224, 3), dtype=np.float32)
means[: ,:] = (0.485, 0.456, 0.406)
dev = np.zeros((224, 224, 3), dtype=np.float32)
dev[: ,:] = (0.229, 0.224, 0.225)
image = cv.imread("D:/images/space_shuttle.jpg")
rgb = cv.cvtColor(image, code=cv.COLOR_BGR2RGB)
# resize to MobileNet image shape
input_image = cv.resize(src=rgb, dsize=(224, 224))
blob_img = np.float32(input_image) / 255.0
input_x = (blob_img - means) / dev
input_x = input_x.transpose((2, 0, 1))
input_x = np.expand_dims(input_x, 0)
print(input_x.shape)
result_infer = compiled_model([input_x])[output_layer]
result_index = np.argmax(result_infer)
cv.putText(image, labels[result_index], (20, 50), cv.FONT_HERSHEY_SIMPLEX, 1.0, (0, 0, 255), 2)
cv.imshow("OpenVINO2022 + Pythorch ResNet18", image)
cv.waitKey(0)
cv.destroyAllWindows()
if __name__ == "__main__":
resnet_demo()Scan the code to check OpenCV+OpenVIO+Pytorch Systematic learning roadmap
Recommended reading
CV The full stack developer said - From traditional algorithm to deep learning, how to practice
2022 Pit depth learning , I choose Pytorch frame !
Pytorch Easily achieve classic visual tasks
Tutorial recommendation | Pytorch frame CV Development - From introduction to practice
OpenCV4 C++ Study Essential basic grammar knowledge 3
OpenCV4 C++ Study Essential basic grammar knowledge 2
OpenCV4.5.4 Face detection + Five o'clock landmark New functional testing
OpenCV4.5.4 Detailed explanation of face recognition and code demonstration
OpenCV Of binary image analysis Blob Analyze and find the circle
OpenCV4.5.x DNN + YOLOv5 C++ Reasoning
OpenCV4.5.4 Direct support for YOLOv5 6.1 Version model reasoning
OpenVINO2021.4+YOLOX Target detection model deployment test
Than YOLOv5 Not bad YOLOX coming , Official support OpenVINO Reasoning
边栏推荐
- Apache+PHP+MySQL环境搭建超详细!!!
- 16个优秀业务流程管理工具
- Why is the executor thread pool framework introduced
- 【云驻共创】ModelBox隔空作画 绘制你的专属画作
- Data backup and recovery of PgSQL
- Teach you how to cancel computer hibernation
- The difference between the lazy man mode and the hungry man mode
- OpenVINO2022 Dev Tools安装与使用
- Predicate
- 2022年最新四川建筑八大员(电气施工员)模拟题库及答案
猜你喜欢

Methods for comparing float types in the kernel

数字孪生行业案例:智慧港口数字化

Teach you how to view the number of connected people on WiFi in detail how to view the number of connected people on WiFi

Saltstack state state file configuration instance

Bytebase 加入阿里云 PolarDB 开源数据库社区

Microsoft Office Excel 2013 2016 graphic tutorial on how to enable macro function

“拯救”直播带货,一个董宇辉还不够

R for Data Science (notes) -- data transformation (used by filter)

《梦华录》“超点”,鹅被骂冤吗?
![[video tutorial] functions that need to be turned off in win10 system. How to turn off the privacy option in win10 computer](/img/14/0313857adc178ecee4c866a05e54aa.jpg)
[video tutorial] functions that need to be turned off in win10 system. How to turn off the privacy option in win10 computer
随机推荐
Understanding openstack network
【CANN文档速递05期】一文让您了解什么是算子
《梦华录》“超点”,鹅被骂冤吗?
Get to know the data structure of redis - hash
Confirm whether the host is a large terminal or a small terminal
Uninstall tool v3.5.10.5670 single file portable official version
等等党们的胜利!挖矿退潮后,显卡价格全面暴跌
应用实践 | 海量数据,秒级分析!Flink+Doris 构建实时数仓方案
Jsup supports XPath
Fuzzy background of unity (take you to appreciate the hazy beauty of women)
RF_DC系统时钟设置GEN1/GEN2
Some ideas about chaos Engineering
Apache+PHP+MySQL环境搭建超详细!!!
Anti epidemic through science and technology: white paper on network insight and practice of operators | cloud sharing library No.20 recommendation
“拯救”直播带货,一个董宇辉还不够
R for Data Science (notes) -- data transformation (used by filter)
2022年最新四川建筑八大员(电气施工员)模拟题库及答案
Clustered index (clustered index), nonclustered index (nonclustered index)
Wait for the victory of the party! After mining ebb tide, graphics card prices plummeted across the board
Q1: error in JMeter filename must not be null or empty