当前位置:网站首页>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.0
After 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-0200
Means 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/INT8
Python 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
边栏推荐
- R for Data Science (note) -- data transformation (select basic use)
- Jsup supports XPath
- Hutool reads large excel (over 10m) files
- Ribbon源码分析之@LoadBalanced与LoadBalancerClient
- Clustered index (clustered index), nonclustered index (nonclustered index)
- Q1: error in JMeter filename must not be null or empty
- Openstack actual installation and deployment tutorial, openstack installation tutorial
- Audio and video 2020 2021 2022 basic operation and parameter setting graphic tutorial
- Five day summary of software testing
- Uninstall tool v3.5.10.5670 single file portable official version
猜你喜欢
Internet of things? Come and see Arduino on the cloud
Zadig + 洞态 IAST:让安全溶于持续交付
Information theory of popular science Shannon
Data backup and recovery of PgSQL
UART communication (STM32F103 library function)
Cooking business experience of young people: bloggers are busy selling classes and bringing goods, and the organization earns millions a month
PHP OSS file reads and writes files, and workman generates temporary files and outputs them to the browser for download
《梦华录》“超点”,鹅被骂冤吗?
Full link service tracking implementation scheme
思源笔记工具栏中的按钮名称变成了 undefined,有人遇到过吗?
随机推荐
Methods for comparing float types in the kernel
To open the registry
Bytebase joins Alibaba cloud polardb open source database community
苹果不差钱,但做内容“没底气”
Power efficiency test
Landcover100, planned land cover website
年轻人捧红的做饭生意经:博主忙卖课带货,机构月入百万
史上最全DPU厂商大盘点(上)
数字孪生行业案例:智慧港口数字化
苹果、微软、谷歌不再掐架,今年要合力干一件大事
Application practice | massive data, second level analysis! Flink+doris build a real-time data warehouse scheme
Php OSS file read and write file, workerman Generate Temporary file and Output Browser Download
Geoscience remote sensing data collection online
全链路业务追踪落地实践方案
unity实战之lol技能释放范围
Technology implementation | Apache Doris cold and hot data storage (I)
Volcano becomes spark default batch scheduler
Docker installing MySQL
Download steps of STM32 firmware library
Compressed list of redis data structures