DanaHan / Yolov5-in-Deepstream-5.0

Describe how to use yolov5 in Deepstream 5.0
208 stars 56 forks source link

The coordinates of boxes all zero #3

Closed wulixunhua closed 4 years ago

wulixunhua commented 4 years ago

Hi, I run export LD_PRE_LOAD = ./libmyplugins.so deepstream-app -c deepstream_app_config_yoloV5.txt I print the coordinates of boxes , all zero. I print the feature map , all "nan". (I test the yolov5s.engine , the feature map is right.) How reasons?

DanaHan commented 4 years ago

You should confirm your model can run correct in Tensorrt. Maybe you can try pre-trained model.

wulixunhua commented 4 years ago

@DanaHan Yes, I use the "tensorrtx" model directly and I have confirmed the model can run correct in tensorrt. But I run the engine on deepstream ,the the coordinates of boxes all zero.

DanaHan commented 4 years ago

@wulixunhua I just test yolov5s model in fp16. Once a time, I also get NAN or zero output. Because the output layer.buffer is only a pointer, so convert need to be done. In my test, unsigned int is correct in my model.

wulixunhua commented 4 years ago

@DanaHan I print the last feature map as follow:

static bool NvDsInferParseYoloV5( std::vector<NvDsInferLayerInfo> const& outputLayersInfo, 
NvDsInferNetworkInfo const& networkInfo, 
NvDsInferParseDetectionParams const& detectionParams, 
std::vector<NvDsInferParseObjectInfo>& objectList) 
{ 
    float *layer = (float *)outputLayersInfo[0].buffer; 
    for(int i=0; i<30; i++) 
        std::cout << layer[i] << " "; 
    std::cout << std::endl; 
    ... 
    ...
 }

The results are "8303 nan nan nan nan nan 0 nan nan nan nan nan 0 nan nan nan nan nan 0 nan ...."

Then I modify float to unsigned int, but get also zero coordinates and huge numbers of last feature map. Can you provide your specific steps? Thank you.

DanaHan commented 4 years ago

This repos only suitable for engine model convert from https://github.com/wang-xinyu/tensorrtx. If you get engine file follow as ONNX->Engine. The parse maybe different.

hxk11111 commented 4 years ago

@DanaHan I converted engine model from tensorrtx, but got the same result with @wulixunhua

DanaHan commented 4 years ago

Sorry, I forget an important step in readme. You should replace yololayer.cu and hardswish.cu to tensrortx/yolov5. And then generate engine model.

And please report whether this step can correct your problem.

hxk11111 commented 4 years ago

@DanaHan Sorry, I didn't get the point. What should I replace with for yololayer.cu and hardswish.cu?

DanaHan commented 4 years ago

@DanaHan Sorry, I didn't get the point. What should I replace with for yololayer.cu and hardswish.cu?

Just find yololayer.cu and hardswish.cu in tensrortx/yolov5 and delete . Then put my modified file to tensrortx/yolov5.

hxk11111 commented 4 years ago

@DanaHan Sorry, I didn't get the point. What should I replace with for yololayer.cu and hardswish.cu?

Just find yololayer.cu and hardswish.cu in tensrortx/yolov5 and delete . Then put my modified file to tensrortx/yolov5.

Got it, thanks, I will try

wulixunhua commented 4 years ago

@DanaHan I put your modified file yololayer.cu and hardswish.cu to test ,the results right. Thank you.