UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Contributor
Contributor
331 Views
Registered: ‎03-06-2019

DPU softmax with yolov3

As I understand, last layer of yolov3 contains the information about class probability, confidence score and bbox coordinates. I know DPU has a softmax module but how to apply the softmax module on partial output channels and some other operations on the other channels?

0 Kudos
4 Replies
Xilinx Employee
Xilinx Employee
277 Views
Registered: ‎03-27-2013

回复: DPU softmax with yolov3

Hi @baharlab ,

 

Have you checked the DNNDK example at  xilinx_dnndk_v3.1/ZCU102/samples/adas_detection/src

There is a function postProcess() show a reference to how to do post process after the running of DPU for YOLO-v3 network.

Hope that can help.

Best Regards,
Jason
-----------------------------------------------------------------------------------------------
Please mark the Answer as "Accept as solution" if the information provided is helpful.

Give Kudos to a post which you think is helpful and reply oriented.
-----------------------------------------------------------------------------------------------
0 Kudos
Contributor
Contributor
259 Views
Registered: ‎03-06-2019

回复: DPU softmax with yolov3

Hi Jason,

I checked with that and found the softmax is done on CPU. But DPU has softmax unit and able to process it on PL. I was wondering how to do that with output from YOLO.

0 Kudos
Xilinx Employee
Xilinx Employee
238 Views
Registered: ‎03-27-2013

回复: DPU softmax with yolov3

Hi @baharlab ,

 

I have checked the DNNDK examples attached in v3.1. Yes, as you said it seems that they call use the CPU caculate softmax function.

I am not sure about the reason for that. I would suggest you to go to the earlier version of DNNDK to get the example of the DPU softmax caculation.

Or you can just refer to this code which I found at resnet50 example at v3.0:

void run_resnet_50(DPUTask *taskConv, const Mat &img, string imname) {
    assert(taskConv );
    // Get the number of category in Resnet_50
    int channel = dpuGetOutputTensorChannel(taskConv, CONV_OUTPUT_NODE);
    // Get the scale of classification result
    float scale = dpuGetOutputTensorScale(taskConv, CONV_OUTPUT_NODE);
    vector<float> smRes (channel);
    int8_t* fcRes;
    // Set the input image to the DPU task
    _T(dpuSetInputImage2(taskConv, CONV_INPUT_NODE, img));
    // Processing the classification in DPU
    _T(dpuRunTask(taskConv));
    // Get the output tensor from DPU in DPU INT8 format
    DPUTensor* dpuOutTensorInt8 = dpuGetOutputTensorInHWCInt8(taskConv, CONV_OUTPUT_NODE);
    // Get the data pointer from the output tensor
    fcRes = dpuGetTensorAddress(dpuOutTensorInt8);
    // Processing softmax in DPU with batchsize=1
    _T(dpuRunSoftmax(fcRes, smRes.data(), channel, 1, scale));
    mutexshow.lock();
    // Show the top 5 classification results with their label and probability
    _T(TopK(smRes.data(), channel, 5, kinds, imname));
    mutexshow.unlock();
}

Please feel free to comment if it goes or not.

 

 

Best Regards,
Jason
-----------------------------------------------------------------------------------------------
Please mark the Answer as "Accept as solution" if the information provided is helpful.

Give Kudos to a post which you think is helpful and reply oriented.
-----------------------------------------------------------------------------------------------
0 Kudos
Participant lucc1
Participant
182 Views
Registered: ‎01-23-2019

回复: DPU softmax with yolov3

I I am pretty sure yolov3 does not use softmax, has I beleive pjreddie(darknet author) took it out in V3 Below is from https://towardsdatascience.com/yolo-v3-object-detection-53fb7d3bfe6b ...snip ... No more softmaxing the classes YOLO v3 now performs multilabel classification for objects detected in images. Earlier in YOLO, authors used to softmax the class scores and take the class with maximum score to be the class of the object contained in the bounding box. This has been modified in YOLO v3. Softmaxing classes rests on the assumption that classes are mutually exclusive, or in simple words, if an object belongs to one class, then it cannot belong to the other. This works fine in COCO dataset. However, when we have classes like Person and Women in a dataset, then the above assumption fails. This is the reason why the authors of YOLO have refrained from softmaxing the classes. Instead, each class score is predicted using logistic regression and a threshold is used to predict multiple labels for an object. Classes with scores higher than this threshold are assigned to the box. ...snip ...
--
Luc Chouinard
FPGA Architect & AI Specialist
Teledyne Imaging
Teledyne Lumenera