Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
87 Views

Caffe Model Optimizer with YOLO Message type "caffe.LayerParameter" has no field named "region_param".

Hi. 
I'm trying without success for a few weeks right now to run YOLO with Intel CPU/GPU via optimized model. I tried YOLO V1 and YOLO V2. To be specific I need the fastest available CNN, so I was trying with Tiny mostly, but with normal YOLO I did not get it to work either.
I have limited resources for use in my project and it is crucial to use as much optimized CNN as possible. Using Intel GPU will be ideal solution, because it is not in use at this moment, so even 100% wouldn't be a problem probably, but I will look later for way to limit it for example to 80%.
In the meantime I will try with SSD now, but it would be great if there is a solution for my problem so at the end I could use Tiny-YOLO or Tiny-YOLO v2.

So I'm encountering error while trying to generate IR with translated file to Caffe:

Framework plugin: CAFFE
Network type: SEGMENTATION EDIT: I did also try CLASSIFICATION (stupid, but I did try..) and LOCALIZATION.
Batch size: 1
Precision: FP32
Layer fusion: false
Horizontal layer fusion: NONE
Output directory: Artifacts
Custom kernels directory: 
Network input normalization: 1
[libprotobuf ERROR google/protobuf/text_format.cc:288] Error parsing text-format caffe.NetParameter: 412:18: Message type "caffe.LayerParameter" has no field named "region_param".
F0301 03:19:45.189383  8739 upgrade_proto.cpp:90] Check failed: ReadProtoFromTextFile(param_file, param) Failed to parse NetParameter file: /home/ubuntu/models/tiny-yolo-voc.prototxt
*** Check failure stack trace: ***
    @     0x7f8a1122a5cd  google::LogMessage::Fail()
    @     0x7f8a1122c433  google::LogMessage::SendToLog()
    @     0x7f8a1122a15b  google::LogMessage::Flush()
    @     0x7f8a1122ce1e  google::LogMessageFatal::~LogMessageFatal()
    @     0x7f8a11758221  caffe::ReadNetParamsFromTextFileOrDie()
    @     0x7f8a11618a5e  readTopology_
    @     0x7f8a13386557  Model2OpenVX::CaffeNetworkDescriptor::CaffeNetworkDescriptor()
    @     0x7f8a1338d5da  Model2OpenVX::CaffeNet::init()
    @     0x7f8a14143c48  Model2OpenVX::FrameworkManager::GenerateIRFile()
    @     0x556489d35ee1  main
    @     0x7f8a138d5830  __libc_start_main
    @     0x556489d37419  _start
    @              (nil)  (unknown)
Aborted (core dumped)

So I investigated files and there is no implementation for "region_param" in Caffe. I didn't found any Caffe version with implemented "region_param".
I did use this repo for translating Darknet to Caffe: https://github.com/marvis/pytorch-caffe-darknet-convert
And using this Caffe files (.prototxt and .caffemodel) works with detect.py. I did check it and it uses CaffeNet not Darknet. 

It is not clear which YOLO is supported by Intel Inference Engine, because here: https://software.intel.com/en-us/inference-engine-devguide-object-detection-for-yolo-sample we can read that this program is for YOLO V1.
And here: https://software.intel.com/en-us/inference-engine-devguide-introduction we can read that it supports YOLO V2.

I did use .weights and .cfg from https://pjreddie.com/darknet/yolo/
 

This is my .prototxt:

name: "Darkent2Caffe"
input: "data"
input_dim: 1
input_dim: 3
input_dim: 416
input_dim: 416

layer {
    bottom: "data"
    top: "layer1-conv"
    name: "layer1-conv"
    type: "Convolution"
    convolution_param {
        num_output: 16
        kernel_size: 3
        pad: 1
        stride: 1
        bias_term: false
    }
}
layer {
    bottom: "layer1-conv"
    top: "layer1-conv"
    name: "layer1-bn"
    type: "BatchNorm"
    batch_norm_param {
        use_global_stats: true
    }
}
layer {
    bottom: "layer1-conv"
    top: "layer1-conv"
    name: "layer1-scale"
    type: "Scale"
    scale_param {
        bias_term: true
    }
}
layer {
    bottom: "layer1-conv"
    top: "layer1-conv"
    name: "layer1-act"
    type: "ReLU"
    relu_param {
        negative_slope: 0.1
    }
}
layer {
    bottom: "layer1-conv"
    top: "layer2-maxpool"
    name: "layer2-maxpool"
    type: "Pooling"
    pooling_param {
        kernel_size: 2
        stride: 2
        pool: MAX
    }
}
layer {
    bottom: "layer2-maxpool"
    top: "layer3-conv"
    name: "layer3-conv"
    type: "Convolution"
    convolution_param {
        num_output: 32
        kernel_size: 3
        pad: 1
        stride: 1
        bias_term: false
    }
}
layer {
    bottom: "layer3-conv"
    top: "layer3-conv"
    name: "layer3-bn"
    type: "BatchNorm"
    batch_norm_param {
        use_global_stats: true
    }
}
layer {
    bottom: "layer3-conv"
    top: "layer3-conv"
    name: "layer3-scale"
    type: "Scale"
    scale_param {
        bias_term: true
    }
}
layer {
    bottom: "layer3-conv"
    top: "layer3-conv"
    name: "layer3-act"
    type: "ReLU"
    relu_param {
        negative_slope: 0.1
    }
}
layer {
    bottom: "layer3-conv"
    top: "layer4-maxpool"
    name: "layer4-maxpool"
    type: "Pooling"
    pooling_param {
        kernel_size: 2
        stride: 2
        pool: MAX
    }
}
layer {
    bottom: "layer4-maxpool"
    top: "layer5-conv"
    name: "layer5-conv"
    type: "Convolution"
    convolution_param {
        num_output: 64
        kernel_size: 3
        pad: 1
        stride: 1
        bias_term: false
    }
}
layer {
    bottom: "layer5-conv"
    top: "layer5-conv"
    name: "layer5-bn"
    type: "BatchNorm"
    batch_norm_param {
        use_global_stats: true
    }
}
layer {
    bottom: "layer5-conv"
    top: "layer5-conv"
    name: "layer5-scale"
    type: "Scale"
    scale_param {
        bias_term: true
    }
}
layer {
    bottom: "layer5-conv"
    top: "layer5-conv"
    name: "layer5-act"
    type: "ReLU"
    relu_param {
        negative_slope: 0.1
    }
}
layer {
    bottom: "layer5-conv"
    top: "layer6-maxpool"
    name: "layer6-maxpool"
    type: "Pooling"
    pooling_param {
        kernel_size: 2
        stride: 2
        pool: MAX
    }
}
layer {
    bottom: "layer6-maxpool"
    top: "layer7-conv"
    name: "layer7-conv"
    type: "Convolution"
    convolution_param {
        num_output: 128
        kernel_size: 3
        pad: 1
        stride: 1
        bias_term: false
    }
}
layer {
    bottom: "layer7-conv"
    top: "layer7-conv"
    name: "layer7-bn"
    type: "BatchNorm"
    batch_norm_param {
        use_global_stats: true
    }
}
layer {
    bottom: "layer7-conv"
    top: "layer7-conv"
    name: "layer7-scale"
    type: "Scale"
    scale_param {
        bias_term: true
    }
}
layer {
    bottom: "layer7-conv"
    top: "layer7-conv"
    name: "layer7-act"
    type: "ReLU"
    relu_param {
        negative_slope: 0.1
    }
}
layer {
    bottom: "layer7-conv"
    top: "layer8-maxpool"
    name: "layer8-maxpool"
    type: "Pooling"
    pooling_param {
        kernel_size: 2
        stride: 2
        pool: MAX
    }
}
layer {
    bottom: "layer8-maxpool"
    top: "layer9-conv"
    name: "layer9-conv"
    type: "Convolution"
    convolution_param {
        num_output: 256
        kernel_size: 3
        pad: 1
        stride: 1
        bias_term: false
    }
}
layer {
    bottom: "layer9-conv"
    top: "layer9-conv"
    name: "layer9-bn"
    type: "BatchNorm"
    batch_norm_param {
        use_global_stats: true
    }
}
layer {
    bottom: "layer9-conv"
    top: "layer9-conv"
    name: "layer9-scale"
    type: "Scale"
    scale_param {
        bias_term: true
    }
}
layer {
    bottom: "layer9-conv"
    top: "layer9-conv"
    name: "layer9-act"
    type: "ReLU"
    relu_param {
        negative_slope: 0.1
    }
}
layer {
    bottom: "layer9-conv"
    top: "layer10-maxpool"
    name: "layer10-maxpool"
    type: "Pooling"
    pooling_param {
        kernel_size: 2
        stride: 2
        pool: MAX
    }
}
layer {
    bottom: "layer10-maxpool"
    top: "layer11-conv"
    name: "layer11-conv"
    type: "Convolution"
    convolution_param {
        num_output: 512
        kernel_size: 3
        pad: 1
        stride: 1
        bias_term: false
    }
}
layer {
    bottom: "layer11-conv"
    top: "layer11-conv"
    name: "layer11-bn"
    type: "BatchNorm"
    batch_norm_param {
        use_global_stats: true
    }
}
layer {
    bottom: "layer11-conv"
    top: "layer11-conv"
    name: "layer11-scale"
    type: "Scale"
    scale_param {
        bias_term: true
    }
}
layer {
    bottom: "layer11-conv"
    top: "layer11-conv"
    name: "layer11-act"
    type: "ReLU"
    relu_param {
        negative_slope: 0.1
    }
}
layer {
    bottom: "layer11-conv"
    top: "layer12-maxpool"
    name: "layer12-maxpool"
    type: "Pooling"
    pooling_param {
        kernel_size: 2
        stride: 1
        pool: MAX
    }
}
layer {
    bottom: "layer12-maxpool"
    top: "layer13-conv"
    name: "layer13-conv"
    type: "Convolution"
    convolution_param {
        num_output: 1024
        kernel_size: 3
        pad: 1
        stride: 1
        bias_term: false
    }
}
layer {
    bottom: "layer13-conv"
    top: "layer13-conv"
    name: "layer13-bn"
    type: "BatchNorm"
    batch_norm_param {
        use_global_stats: true
    }
}
layer {
    bottom: "layer13-conv"
    top: "layer13-conv"
    name: "layer13-scale"
    type: "Scale"
    scale_param {
        bias_term: true
    }
}
layer {
    bottom: "layer13-conv"
    top: "layer13-conv"
    name: "layer13-act"
    type: "ReLU"
    relu_param {
        negative_slope: 0.1
    }
}
layer {
    bottom: "layer13-conv"
    top: "layer14-conv"
    name: "layer14-conv"
    type: "Convolution"
    convolution_param {
        num_output: 1024
        kernel_size: 3
        pad: 1
        stride: 1
        bias_term: false
    }
}
layer {
    bottom: "layer14-conv"
    top: "layer14-conv"
    name: "layer14-bn"
    type: "BatchNorm"
    batch_norm_param {
        use_global_stats: true
    }
}
layer {
    bottom: "layer14-conv"
    top: "layer14-conv"
    name: "layer14-scale"
    type: "Scale"
    scale_param {
        bias_term: true
    }
}
layer {
    bottom: "layer14-conv"
    top: "layer14-conv"
    name: "layer14-act"
    type: "ReLU"
    relu_param {
        negative_slope: 0.1
    }
}
layer {
    bottom: "layer14-conv"
    top: "layer15-conv"
    name: "layer15-conv"
    type: "Convolution"
    convolution_param {
        num_output: 125
        kernel_size: 1
        pad: 0
        stride: 1
        bias_term: true
    }
}
layer {
    bottom: "layer15-conv"
    top: "layer16-region"
    name: "layer16-region"
    type: "Region"
    region_param {
        anchors: "1.08,1.19,  3.42,4.41,  6.63,11.38,  9.42,5.11,  16.62,10.52"
        classes: 20
        num: 5
    }
}

 

0 Kudos
3 Replies
Highlighted
Employee
87 Views

Thanks for your detailed report. I have submitted your query to the development team. Someone will answer your question soon. Thanks !

0 Kudos
Highlighted
87 Views

Hi Tomasz,

 

Thank you for your interest to the project.

 

According to the error message, [libprotobuf ERROR google/protobuf/text_format.cc:288] Error parsing text-format caffe.NetParameter: 412:18: Message type "caffe.LayerParameter" has no field named "region_param".
F0301 03:19:45.189383  8739 upgrade_proto.cpp:90] Check failed: ReadProtoFromTextFile(param_file, param) Failed to parse NetParameter file: /home/ubuntu/models/tiny-yolo-voc.prototxt

You are trying to load the model with inapropriate Caffe. Could you please specify what version of Caffe have you configured on your machine?

AFAIK, this is not a Yolo v1 model. The topology you provided looks like Yolo v2 and has a layer "Region". However, it is not a common RegionYolo layer - it has "anchors" instead of "coords". It is critical to find appropriate Caffe that could load such a model and only then think about using MO as it is tightly coupled with Caffe in aspect of loading the model.

Please note, that even after conversion to IR, you need to implement that layer as IE extension. For more details, refer to the tutorial: https://software.intel.com/en-us/cvsdk-object-detection-with-inference-engine-tutorial 

Please share any issues you face, we will try to respond asap.

 

 

 

 

0 Kudos
Highlighted
Beginner
87 Views

Hi,
Thank you for answer and interest in my problem.
I successfully tested and run MO and IR for SSD and it is fast enough for our purpose. So for now I'm working on building data for training SSD.
If I go back to YOLO and I wouldn't be able to solve my problems I will write.

Once again, thanks for answering.

0 Kudos