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: 
Visitor frankzhao92
Visitor
922 Views
Registered: ‎07-05-2018

Yolov3 in CHaiDNNv2

Hello,

I am trying to implement Yolov3 network(s) in CHaiDNN. I have begun with Yolov3-tiny network (as it is a smaller and therefore hopefully easier to implement) I have converted Yolov3-tiny from Darknet framework to Caffemodel and prototxt files. This conversion requires some new layers to be implemented in caffe, one for upsampling the blobs and one final layer for calculating the Boxpoints and prediction results.

From what I understand, if the only layer was the final output calculation layer, I could just forgo that layer on hardware and run those calculations on CPU after the hardware finishes processing the last convolution layer. However, in this case the upsampling layer is placed between convolution layers and I can't use that trick. 

I have implemented the upsampling layer (this layer has no weights) following the instructions on the software plugin layer readme and successfully compiled CHaiDNN software. When I try to run the XportDNN.pyc python tool on my new Yolov3-tiny prototxt file, I get a error something like "user_defined_layer : true is not a parameter of layer.parameter". If I remove user_defined_layer parameter, it will say "unknown layer type : Upsample". It seems the quantize.pyc tool does not recognise my new layer either.

My question is how does one create quantized prototxt and caffemodel files for a network with a software plugin layer?

For reference the main code for upsampling layer is 

for (int n = 0; n < N; n++) {
    for (int c = 0; c < C; c++) {
        for (int h = 0; h < H; h++) {
            for (int w = 0; w < W; w++) {
                int nw = w/scale_;
                int nh = h/scale_;
                int out_idx = (((n * C + c) * H) + h) * W + w;
                int in_idx = (((n * C + c) * (H / scale_)) + nh) * (W / scale_) + nw;
                output[out_idx] = input[in_idx];
            }
        }
    }
}

Where N,C,H and W are the output shapes and scale_ is how many times you are upsampling each pixel in channel, height and width. For example in Yolov3-tiny, the scale is 2 and the blob shape of input 1 128 13 13 is transformed to output shape 1 256 26 26. Maybe you guys have some tricks to do this with the currently implemented layers?

 

Thanks,

Frank

0 Kudos
4 Replies
Explorer
Explorer
802 Views
Registered: ‎10-24-2008

Re: Yolov3 in CHaiDNNv2

@vkjainI see that @frankzhao92 has already confirmed that his environment matches what 'zjchenchujie' has posted here: https://github.com/Xilinx/CHaiDNN/issues/86

It thus seems that this is not likely an environment issue.  Do you have any additional thoughts as to where the source of this issue might lie?

--Quenton

 

 

0 Kudos
Highlighted
Xilinx Employee
Xilinx Employee
780 Views
Registered: ‎07-25-2018

Re: Yolov3 in CHaiDNNv2

Hi @frankzhao92@qhall,

 

Software layer plugin is useful when the layer is not supported by CHaiDNN but is a part of standard Caffe and supported by XportDNN. As the Upsampling Layer is not implemented in standard Caffe, the quantize.pyc does not recognize the layer name.

Hence the errors while running quantization.

Thanks!

 

Explorer
Explorer
770 Views
Registered: ‎10-24-2008

Re: Yolov3 in CHaiDNNv2

@vkjain@frankzhao92  Thanks Vishal!  Yes, indeed that makes perfect sense.  Thanks for your follow-up on this!

--Quenton

0 Kudos
Newbie jwy
Newbie
579 Views
Registered: ‎01-28-2019

Re: Yolov3 in CHaiDNNv2

hello,but how should I add upsample layers and rebuild caffe? In other words,how should i change the tools for YOLOv3?

0 Kudos