当前位置:网站首页>The programmer's girlfriend gave me a fatigue driving test
The programmer's girlfriend gave me a fatigue driving test
2022-06-30 23:39:00 【InfoQ】

Development background

Algorithm principle




ModelBox Introduce
Easy to develop
AI Reasoning business visual choreography development , Function modularization , Rich component library ;c++,python Multilingual support .
Easy to integrate
Integrate components docked on the cloud , Cloud docking is easier .
High performance , Highly reliable
pipeline Run concurrently , Data computing intelligent scheduling , Refinement of resource management and scheduling , Business operation is more efficient .
Heterogeneous software and hardware
CPU,GPU,NPU Multi heterogeneous hardware support , More convenient and efficient use of resources .
The whole scene
video , voice , Text ,NLP The whole scene , Customized for service , Cloud integration is easier , Seamless exchange of end cloud data .
Easy to maintain
Visualization of service running status , application , Real time monitoring of component performance , Optimization is easier .
model training

Model transformation

Development environment deployment

application development
Create a project
[email protected]:~/yourpath/v1.0.8.21$ sudo ./create.py -h
Usage: Create ModelBox project and flowunit
NOTE : you must firstly use bellow cmd to create a project in workspace
create.py -t server -n your_proj_name {option: -s name, create this project from a solution}, support hilens deployment
or create.py -t project -n your_proj_name {option: -s name, create this project from a solution}, generally not use
AND : use bellow cmd to create [c++|python|infer] flowunit in this project
create.py -t c++ -n your_flowunit_name -p your_proj_name
AND : call workspace/your_proj_name/build_project.sh to build your project, call bin/main.sh[bat] to run
FINAL: create.py -t rpm -n your_proj_name to package your project (the same folder with create.py) if upload to hilens
NOTE: create.py -t editor {option: -i ip or ip:port to start editor server in your config ip:port}
NOTE: create.py -t demo to create solutions to runnable demo
for ex: create.py -t server -n my_det -s car_det
-h or --help:show help
-t or --template [c++|python|infer|yolo|project|server|rpm|editor|demo] create a template or package to rpm ...
-n or --name [your template name]
-p or --project [your project name when create c++|python|infer|yolo]
-s or --solution [the solution name when create project] create a project from solution
-c or --cfg [flowunit configure json, it's used by UI, you can use it too, but too complicated]
-v or --version:show sdk version





Create reasoning function flow unit





Create post-processing function unit



Flow chart layout













Code completion

`video_decoder [ type=flowunit flowunit=video_decoder device=rknpu deviceid="0" pix_fmt=bgr label="{{<in_video_packet> in_video_packet}|video_decoder|{<out_video_frame> out_video_frame}}" ]`
** Reasoning unit **
[flowunit-name]
|---[flowunit-name].toml # Inference function unit configuration
|---[model].rknn # Model file
|---[infer-plugin].so # Reasoning custom plug-ins

[FlowUnitName]
|---[FlowUnitName].toml
|---[FlowUnitName].py
|---xxx.py

# Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import _flowunit as modelbox
class face_detect_postFlowUnit(modelbox.FlowUnit):
# Derived from modelbox.FlowUnit
def __init__(self):
super().__init__()
def open(self, config):
# Open the flowunit to obtain configuration information
return modelbox.Status.StatusCode.STATUS_SUCCESS
def process(self, data_context):
# Process the data
in_data = data_context.input("in_1")
out_data = data_context.output("out_1")
# yolox_post process code.
# Remove the following code and add your own code here.
for buffer in in_data:
response = "Hello World " + buffer.as_object()
result = response.encode('utf-8').strip()
add_buffer = modelbox.Buffer(self.get_bind_device(), result)
out_data.push_back(add_buffer)
return modelbox.Status.StatusCode.STATUS_SUCCESS
def close(self):
# Close the flowunit
return modelbox.Status()
def data_pre(self, data_context):
# Before streaming data starts
return modelbox.Status()
def data_post(self, data_context):
# After streaming data ends
return modelbox.Status()
def data_group_pre(self, data_context):
# Before all streaming data starts
return modelbox.Status()
def data_group_post(self, data_context):
# After all streaming data ends
return modelbox.Status()
def process(self, data_context):
# Process the data
in_image = data_context.input("image")
in_feat = data_context.input("in_feat")
in_score = data_context.input("in_score")
has_face = data_context.output("has_face")
no_face = data_context.output("no_face")
# face_detect_post process code.
# Remove the following code and add your own code here.
for buffer_img, buffer_feat, buffer_score in zip(in_image, in_feat, in_score):
width = buffer_img.get('width')
height = buffer_img.get('height')
channel = buffer_img.get('channel')
img_data = np.array(buffer_img.as_object(), copy=False)
img_data = img_data.reshape((height, width, channel))
feat_data = np.array(buffer_feat.as_object(), copy=False)
feat_data = feat_data.reshape(896,16)
feat_score = np.array(buffer_score.as_object(), copy=False)
feat_score = feat_score.reshape(896,1)
dets = process_cpu(feat_data, feat_score, self.anchors)
if dets.shape[0] > 0:
box = [int(dets[0]*width), int(dets[1]*height),int(dets[2]*width),int(dets[3]*height)]
box = self.expend(box, height, width)
buffer_img.set("bboxes", box)
has_face.push_back(buffer_img)
else:
img_buffer = modelbox.Buffer(self.get_bind_device(), img_data)
img_buffer.copy_meta(buffer_img)
no_face.push_back(img_buffer)
return modelbox.Status.StatusCode.STATUS_SUCCESS
# For local mock File reading task , The script has been configured IVA_SVC_CONFIG environment variable , Added this file path
########### Please make sure to use linux Path type , For example windows Use D:/xxx/xxx Out-of-service D:\xxx\xxx ###########
# The task parameter is a compressed and escaped json character string
# Writing directly requires escaping double quotation marks , It can also be used. content_file Add one json file , If content and content_file All exist content Will be covered
# content_file Support absolute path or relative path , Parsing environment variables... Is not supported ( Include ${HILENS_APP_ROOT}、${HILENS_DATA_DIR} etc. )
[common]
content = "{\"param_str\":\"string param\",\"param_int\":10,\"param_float\":10.5}"
# Task input ,mock Simulation currently only supports one way rtsp Or local url
# rtsp camera ,type = "rtsp", url Write in rtsp Address
# Other uses "url", For example, it can be a local file address , perhaps httpserver The address of ,( camera url = "0")
[input]
type = "url"
url = "../data/fatigue.mp4"
# Task output , Currently only supported "webhook", And local output "local"( Output to the screen ,url="0", Output to rtsp, Fill in rtsp Address )
# (local You can also export to a local file , Pay attention to , Files can be relative paths , Is relative to this mock_task.toml The document itself )
[output]
type = "local"
url = "../hilens_data_dir/fatigue.mp4"
[email protected]:~/yourpath/v1.0.8.21/workspace/fatigue_detect$ sudo ./build_project.sh
./build_project.sh: line 26: dos2unix: command not found
./build_project.sh: line 26: dos2unix: command not found
./build_project.sh: line 26: dos2unix: command not found
./build_project.sh: line 26: dos2unix: command not found
./build_project.sh: line 26: dos2unix: command not found
./build_project.sh: line 26: dos2unix: command not found
./build_project.sh: line 26: dos2unix: command not found
./build_project.sh: line 26: dos2unix: command not found
build success: you can run main.sh in ./bin folder Copy
[email protected]:~/yourpath/v1.0.8.21/workspace/fatigue_detect$ sudo ./bin/main.sh Copy


边栏推荐
- Error when starting PHP: [pool www] cannot get uid for user '@php_ fpm_ [email protected]’
- 未来十年世界数字化与机器智能展望
- shell 同时执行多任务下载视频
- Is it safe to choose mobile phone for stock trading account opening in Hangzhou?
- Swift 5.0 - creation and use of swift framework
- 唯一性索引与逻辑删除冲突问题解决思路
- Detailed explanation of conv2d of pytorch
- Repetition is the mother of skill
- Schéma de transition asynchrone - générateur
- Youfu network hybrid cloud accelerates enterprise digital transformation and upgrading
猜你喜欢
76页智慧物流园区综合解决方案2022(附下载)
CesiumJS 2022^ 源码解读[6] - 三维模型(ModelExperimental)新架构
5g smart building solution 2021
Combining online and offline, VR panorama is a good way to transform furniture online!
Solution to the conflict between unique index and logical deletion
女朋友说:你要搞懂了MySQL三大日志,我就让你嘿嘿嘿!
Two way data binding in wechat applet
一次革命、两股力量、三大环节:《工业能效提升行动计划》背后的“减碳”路线图
IFLYTEK active competition summary! (12)
Software supply chain security risk pointing North for enterprise digitalization and it executives
随机推荐
2022-06-30:以下golang代码输出什么?A:0;B:2;C:运行错误。 package main import “fmt“ func main()
Ride: get picture Base64
Combining online and offline, VR panorama is a good way to transform furniture online!
Fund managers' corporate governance and risk management
What is SRM system and how to standardize the internal procurement process of the company
在指南针上买基金安全吗?
Solution to the conflict between unique index and logical deletion
Qt笔记(七十四)之QLineEdit指定输入类型
Kubevela 1.4: make application delivery safer, easier to use, and more transparent
CesiumJS 2022^ 源码解读[6] - 三维模型(ModelExperimental)新架构
"Paddle + camera" has become a "prefabricated dish" in the AI world, and it is easier to implement industrial AI quality inspection
Detailed explanation of conv2d -- use in arrays and images
The girlfriend said: if you want to understand the three MySQL logs, I will let you heiheihei!
How to use dataant to monitor Apache APIs IX
How to use robots Txt and its detailed explanation
Solve arm_ release_ ver of this libmali is ‘g2p0-01eac0‘,rk_ so_ Ver is' 4 ', libgl1 mesa dev will not be installed, and there are unsatisfied dependencies
Operation record of reinitialization instance of Dameng database
E-commerce seckill system
PS2 handle-1 "recommended collection"
LVM snapshot: backup based on LVM snapshot