vitis::ai::MultiTask

Multitask Network Type , declaration multitask Network.

number of classes label: 0 name: "background" label: 1 name: "person" label: 2 name: "car" label: 3 name: "truck" label: 4 name: "bus" label: 5 name: "bike" label: 6 name: "sign" label: 7 name: "light"

Base class for ADAS MuiltTask from an image (cv::Mat).

Input an image (cv::Mat).

Output is a struct of MultiTaskResult include segmentation results, detection results and vehicle towards;

Sample code:

auto det = vitis::ai::MultiTask::create("multi_task");
auto image = cv::imread("sample_multitask.jpg");
auto result = det->run_8UC3(image);
cv::imwrite("sample_multitask_result.jpg",result.segmentation);

Display of the model results:

Figure 1: result image

Image sample_multitask_result.jpg

Quick Function Reference

The following table lists all the functions defined in the vitis::ai::MultiTask class:

Table 1. Quick Function Reference
TypeNameArguments
std::unique_ptr< MultiTask >create
  • const std::string & model_name
  • bool need_preprocess
intgetInputWidth
  • void
intgetInputHeight
  • void
size_tget_input_batch
  • void
MultiTaskResultrun_8UC1
  • const cv::Mat & image
std::vector< MultiTaskResult >run_8UC1
  • const std::vector< cv::Mat > & images
MultiTaskResultrun_8UC3
  • const cv::Mat & image
std::vector< MultiTaskResult >run_8UC3
  • const std::vector< cv::Mat > & images

create

Factory function to get an instance of derived classes of class Multitask.

Prototype

std::unique_ptr< MultiTask > create(const std::string &model_name, bool need_preprocess=true);

Parameters

The following table lists the create function arguments.

Table 2. create Arguments
Type Name Description
const std::string & model_name Model name
bool need_preprocess Normalize with mean/scale or not, default value is true.

Returns

An instance of Multitask class.

getInputWidth

Function to get InputWidth of the multitask network (input image columns).

Prototype

int getInputWidth() const =0;

Returns

InputWidth of the multitask network.

getInputHeight

Function to get InputHeight of the multitask network (input image rows).

Prototype

int getInputHeight() const =0;

Returns

InputHeight of the multitask network.

get_input_batch

Function to get the number of images processed by the DPU at one time.

Note: Different DPU core the batch size may be different. This depends on the IP used.

Prototype

size_t get_input_batch() const =0;

Returns

Batch size.

run_8UC1

Function of get running result from the MultiTask network.

Note: The type is CV_8UC1 of the MultiTaskResult.segmentation.

Prototype


            MultiTaskResult run_8UC1(const cv::Mat &image)=0;

Parameters

The following table lists the run_8UC1 function arguments.

Table 3. run_8UC1 Arguments
Type Name Description
const cv::Mat & image Input image

Returns

The struct of MultiTaskResult

run_8UC1

Function to get running results of the MultiTask neuron network in batch mode.

Note: The type is CV_8UC1 of the MultiTaskResult.segmentation.

Prototype

std::vector< MultiTaskResult > run_8UC1(const std::vector< cv::Mat > &images)=0;

Parameters

The following table lists the run_8UC1 function arguments.

Table 4. run_8UC1 Arguments
Type Name Description
const std::vector< cv::Mat > & images Input data of input images (std:vector<cv::Mat>). The size of input images equals batch size obtained by get_input_batch.

Returns

The vector of MultiTaskResult.

run_8UC3

Function to get running result from the MultiTask network.

Note: The type is CV_8UC3 of the MultiTaskResult.segmentation.

Prototype


            MultiTaskResult run_8UC3(const cv::Mat &image)=0;

Parameters

The following table lists the run_8UC3 function arguments.

Table 5. run_8UC3 Arguments
Type Name Description
const cv::Mat & image Input image;

Returns

The struct of MultiTaskResult

run_8UC3

Function to get running results of the MultiTask neuron network in batch mode.

Note: The type is CV_8UC3 of the MultiTaskResult.segmentation.

Prototype

std::vector< MultiTaskResult > run_8UC3(const std::vector< cv::Mat > &images)=0;

Parameters

The following table lists the run_8UC3 function arguments.

Table 6. run_8UC3 Arguments
Type Name Description
const std::vector< cv::Mat > & images Input data of input images (std:vector<cv::Mat>). The size of input images equals batch size obtained by get_input_batch.

Returns

The vector of MultiTaskResult.