当前位置:网站首页>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 

边栏推荐
- CNN classic network model details -lenet-5 (pytorch Implementation)
- Redis' cache penetration, cache breakdown and cache avalanche
- 1175. 质数排列 / 剑指 Offer II 104. 排列的数目
- Online customer service chat system source code_ Beautiful and powerful golang kernel development_ Binary operation fool installation_ Attached construction tutorial
- Redis' transaction and locking mechanism
- Query points in MATLAB Delaunay triangulation
- LVM snapshot: backup based on LVM snapshot
- What is SRM system and how to standardize the internal procurement process of the company
- How to edit special effects in VR panorama? How to display detailed functions?
- Sm2246en+ SanDisk 15131
猜你喜欢

Esp8266 becomes client and server

"Paddle + camera" has become a "prefabricated dish" in the AI world, and it is easier to implement industrial AI quality inspection

MaxPool2d详解--在数组和图像中的应用

Shell multitasking to download video at the same time

Redis' transaction and locking mechanism

206 page Shanghai BIM Technology Application and development report 2021

What does project management really manage?

In 2022, the latest JCR officially released the list of the latest global impact factors (top 600)

如何使用 DataAnt 监控 Apache APISIX

5g smart building solution 2021
随机推荐
Why should VR panoramic shooting join us? Leverage resources to achieve win-win results
什么是SRM系统,如何规范公司内部采购流程
Zero sample and small sample learning
In depth understanding of jetpack compose kernel: slottable system
基金客户服务
35家巨头科技公司联合组成元宇宙标准论坛组织
JMeter cross thread parameter association requires no script
异步过渡方案—Generator
Ctfshow framework reproduction
Don't worry about whether you can be a coder if you don't learn English well. Learn it first
How does the VR cloud exhibition hall bring vitality to offline entities? What are the functions?
Cloud games | cloud computing drives the game industry into a "new era"
CesiumJS 2022^ 源码解读[6] - 三维模型(ModelExperimental)新架构
What is SRM system and how to standardize the internal procurement process of the company
在指南针上买基金安全吗?
Fastjson V2 simple user manual
Software engineering best practices - project requirements analysis
Flitter - sort list sort
DNS server setup, forwarding, master-slave configuration
CesiumJS 2022^ 源码解读[6] - 三维模型(ModelExperimental)新架构