当前位置:网站首页>Code demonstration of fcos face detection model in openvino
Code demonstration of fcos face detection model in openvino
2022-07-19 03:03:00 【Xiaobai learns vision】
Click on the above “ Xiaobai studies vision ”, Optional plus " Star standard " or “ Roof placement ”
Heavy dry goods , First time delivery
Model input and output
OpenVINO 2020R04 There are two face detection models labeled :
face-detection-0105 – MobileNetv2 + FCOS
face-detection-0106 – RestNet152 + ATSS
There's a little bit of caution here ,FCOS And ATSS Model detection head output follows SSD Different models , Officially supported IR The file has two output data, which are :
boxes: [Nx5],
labels:[N]
among N Indicates the number of prediction frames obtained ,5 Represents the coordinates of the upper left and lower right corners of the prediction box , Plus the classification score -5 Elements are :
[x_min, y_min, x_max, y_max, conf]
Here is the special note , Follow SSD And FasterRCNN The object detection network is different , It outputs real coordinate information based on the size of the input image , No 0~1 Between the value of the . The input format is :NCHW=[1xNxHxW], Image channel sequence BGR.
Download these two models , Just execute the following script statement :
You can complete the download !
Code demonstration
The code implementation is based on OpenVINO Python SDK, With FCOS For example ! First load the model , The code is as follows :
1from __future__ import print_function
2import cv2
3import time
4import logging as log
5from openvino.inference_engine import IECore
6
7model_xml = "D:/projects/models/face-detection-0105/FP32/face-detection-0105.xml"
8model_bin = "D:/projects/models/face-detection-0105/FP32/face-detection-0105.bin"
9
10log.info("Creating Inference Engine")
11ie = IECore()
12# Read IR
13net = ie.read_network(model=model_xml, weights=model_bin)
Get input and output formatting information
1log.info("Preparing input blobs")
2input_it = iter(net.input_info)
3input_blob = next(input_it)
4print(input_blob)
5output_it = iter(net.outputs)
6out_labels = next(output_it)
7out_boxes = next(output_it)
8
9# Read and pre-process input images
10print(net.input_info[input_blob].input_data.shape)
Convert the input data into NCHW Format
1image = cv2.imread("D:/images/selfie.jpg")
2ih, iw, ic = image.shape
3rh = ih / 416
4rw = iw / 416
5print("rate of height:",rh, "rate of widht:",rw)
6image_blob = cv2.resize(image, (416, 416))
7image_blob = image_blob.transpose(2, 0, 1) # Change data layout from HWC to CHW
8
9# Loading model to the plugin
10exec_net = ie.load_network(network=net, device_name="CPU")
To carry out reasoning
1# Start sync inference
2log.info("Starting inference in synchronous mode")
3inf_start1 = time.time()
4res = exec_net.infer(inputs={input_blob:[image_blob]})
5inf_end1 = time.time() - inf_start1
6print("inference time(ms) : %.3f" % (inf_end1 * 1000))
Analytic output
1# Processing output blob
2log.info("Processing output blob")
3res = res[out_boxes]
4face_cnt = 0
5for obj in res:
6 if float(obj[4]) > 0.25:
7 print(obj)
8 face_cnt += 1
9 xmin = int(obj[0]*rw)
10 ymin = int(obj[1]*rh)
11 xmax = int(obj[2]*rw)
12 ymax = int(obj[3]*rh)
13 cv2.rectangle(image, (xmin, ymin), (xmax, ymax), (0, 0, 255), 2, 8, 0)
14cv2.putText(image, "Total Detected Face: %d"%face_cnt, (50, 50), cv2.FONT_HERSHEY_SIMPLEX, 1.0, (0, 0, 255), 2)
15cv2.imshow("FOCS Face detection", image)
16print("total faces : ", face_cnt)
17cv2.imwrite("D:/result_fcos.png", image)
18cv2.waitKey(0)
19cv2.destroyAllWindows()
The running screenshot is as follows :
The good news !
Xiaobai learns visual knowledge about the planet
Open to the outside world
download 1:OpenCV-Contrib Chinese version of extension module
stay 「 Xiaobai studies vision 」 Official account back office reply : Extension module Chinese course , You can download the first copy of the whole network OpenCV Extension module tutorial Chinese version , Cover expansion module installation 、SFM Algorithm 、 Stereo vision 、 Target tracking 、 Biological vision 、 Super resolution processing and other more than 20 chapters .
download 2:Python Visual combat project 52 speak
stay 「 Xiaobai studies vision 」 Official account back office reply :Python Visual combat project , You can download, including image segmentation 、 Mask detection 、 Lane line detection 、 Vehicle count 、 Add Eyeliner 、 License plate recognition 、 Character recognition 、 Emotional tests 、 Text content extraction 、 Face recognition, etc 31 A visual combat project , Help fast school computer vision .
download 3:OpenCV Actual project 20 speak
stay 「 Xiaobai studies vision 」 Official account back office reply :OpenCV Actual project 20 speak , You can download the 20 Based on OpenCV Realization 20 A real project , Realization OpenCV Learn advanced .
Communication group
Welcome to join the official account reader group to communicate with your colleagues , There are SLAM、 3 d visual 、 sensor 、 Autopilot 、 Computational photography 、 testing 、 Division 、 distinguish 、 Medical imaging 、GAN、 Wechat groups such as algorithm competition ( It will be subdivided gradually in the future ), Please scan the following micro signal clustering , remarks :” nickname + School / company + Research direction “, for example :” Zhang San + Shanghai Jiaotong University + Vision SLAM“. Please note... According to the format , Otherwise, it will not pass . After successful addition, they will be invited to relevant wechat groups according to the research direction . Please do not send ads in the group , Or you'll be invited out , Thanks for your understanding ~
边栏推荐
- 这是数学的问题
- [MCU simulation] (IV) addressing mode register addressing and direct addressing
- 【NoSQL】redis主从、哨兵、集群
- Oracle获取最后一条,第一条数据(按时间获取第一条和最后一条数据)
- HCIA_ Nat experiment
- 多项式插值拟合(一)
- Understand network namespaces
- [MCU simulation] (VI) addressing mode - index addressing and relative addressing
- 【单片机仿真】(二十一)DB(Define Byte)— 定义字节
- Multi layer packet structure and TCP triple handshake
猜你喜欢
Mysql优化之索引
MySQL master-slave replication + read write separation
Full virtualization and semi virtualization
RESNET learning notes
The place where the dream begins ---- first knowing C language
人脸关键点检测
HCIA's first static routing experiment
Redis之简单动态字符串SDS
Understand JVM garbage collection in one article
GFS分布式文件系统
随机推荐
这是数学的问题
4年开发二面美团最终败给:volatile关键字作用和原理这道面试题
[single chip microcomputer simulation] (10) instruction system - multiplication instruction and division of arithmetic operation instruction
[MCU simulation] (VI) addressing mode - index addressing and relative addressing
DHCP service
【单片机仿真】(五)寻址方式 — 立即寻址与寄存器间接寻址
Go语言 实现发送短信验证码 并登录
[redis] what is progressive rehash
【单片机仿真】(十一)指令系统逻辑运算指令 — 逻辑与指令ANL、逻辑或指令ORL
Go language realizes sending SMS verification code and logging in
通过Dao投票STI的销毁,SeekTiger真正做到由社区驱动
Introduction to wangeditor (entry level)
[single chip microcomputer simulation] (XI) instruction system logic operation instruction - logic and instruction anl, logic or instruction ORL
MySQL storage engine details
Comprehensive experiment of static routing
工具及方法 - Excel插件XLTools
【单片机仿真】(十六)控制转移类指令 — 无条件转移指令、条件转移指令
全虚拟化与半虚拟化
时间复杂度和空间复杂度分析技巧
多项式插值拟合(三)