yolo3 parsed ok
This commit is contained in:
@@ -140,15 +140,17 @@ namespace tk { namespace dnn {
|
||||
if(f.type == "convolutional") {
|
||||
std::string wgs = wgs_path + "/c" + std::to_string(netLayers.size()) + ".bin";
|
||||
printf("%d (%d,%d) (%d,%d) (%d,%d) %s %d %d\n", f.filters, f.size_x, f.size_y, f.stride_x, f.stride_y, f.padding_x, f.padding_y, wgs.c_str(), f.batch_normalize, f.groups);
|
||||
netLayers.push_back(new tk::dnn::Conv2d(net, f.filters, f.size_x, f.size_y, f.stride_x,
|
||||
f.stride_y, f.padding_x, f.padding_y, wgs, f.batch_normalize, false, f.groups));
|
||||
tk::dnn::Conv2d *l= new tk::dnn::Conv2d(net, f.filters, f.size_x, f.size_y, f.stride_x,
|
||||
f.stride_y, f.padding_x, f.padding_y, wgs, f.batch_normalize, false, f.groups);
|
||||
if(f.activation != "linear") {
|
||||
tkdnnActivationMode_t act;
|
||||
if(f.activation == "relu") act = tkdnnActivationMode_t(CUDNN_ACTIVATION_RELU);
|
||||
else if(f.activation == "leaky") act = tk::dnn::ACTIVATION_LEAKY;
|
||||
else if(f.activation == "mish") act = tk::dnn::ACTIVATION_MISH;
|
||||
else { FatalError("activation not supported: " + f.activation); }
|
||||
new tk::dnn::Activation(net, act);
|
||||
netLayers.push_back(new tk::dnn::Activation(net, act));
|
||||
} else {
|
||||
netLayers.push_back(l);
|
||||
}
|
||||
} else if(f.type == "shortcut") {
|
||||
if(f.layers.size() != 1) FatalError("no layers to shortcut\n");
|
||||
|
||||
@@ -12,7 +12,6 @@ int main() {
|
||||
tk::dnn::Network *net = tk::dnn::darknetParser("../tests/yolo3/yolov3.cfg", "yolo3/layers");
|
||||
net->print();
|
||||
|
||||
|
||||
std::vector<tk::dnn::Yolo*> yolo;
|
||||
for(int i=0; i<net->num_layers; i++) {
|
||||
if(net->layers[i]->getLayerType() == tk::dnn::layerType_t::LAYER_YOLO)
|
||||
@@ -24,6 +23,10 @@ int main() {
|
||||
yolo[i]->classesNames = {"person" , "bicycle" , "car" , "motorbike" , "aeroplane" , "bus" , "train" , "truck" , "boat" , "traffic light" , "fire hydrant" , "stop sign" , "parking meter" , "bench" , "bird" , "cat" , "dog" , "horse" , "sheep" , "cow" , "elephant" , "bear" , "zebra" , "giraffe" , "backpack" , "umbrella" , "handbag" , "tie" , "suitcase" , "frisbee" , "skis" , "snowboard" , "sports ball" , "kite" , "baseball bat" , "baseball glove" , "skateboard" , "surfboard" , "tennis racket" , "bottle" , "wine glass" , "cup" , "fork" , "knife" , "spoon" , "bowl" , "banana" , "apple" , "sandwich" , "orange" , "broccoli" , "carrot" , "hot dog" , "pizza" , "donut" , "cake" , "chair" , "sofa" , "pottedplant" , "bed" , "diningtable" , "toilet" , "tvmonitor" , "laptop" , "mouse" , "remote" , "keyboard" , "cell phone" , "microwave" , "oven" , "toaster" , "sink" , "refrigerator" , "book" , "clock" , "vase" , "scissors" , "teddy bear" , "hair drier" , "toothbrush"};
|
||||
}
|
||||
|
||||
//convert network to tensorRT
|
||||
tk::dnn::NetworkRT netRT(net, net->getNetworkRTName("yolo3"));
|
||||
|
||||
|
||||
std::string input_bin = bin_path + "/layers/input.bin";
|
||||
std::vector<std::string> output_bins = {
|
||||
bin_path + "/debug/layer82_out.bin",
|
||||
@@ -36,16 +39,12 @@ int main() {
|
||||
dnnType *input_h;
|
||||
readBinaryFile(input_bin, net->input_dim.tot(), &input_h, &data);
|
||||
|
||||
|
||||
//convert network to tensorRT
|
||||
tk::dnn::NetworkRT netRT(net, net->getNetworkRTName("yolo3"));
|
||||
|
||||
// the network have 3 outputs
|
||||
tk::dnn::dataDim_t out_dim[3];
|
||||
for(int i=0; i<3; i++) out_dim[i] = yolo[i]->output_dim;
|
||||
dnnType *cudnn_out[3], *rt_out[3];
|
||||
|
||||
tk::dnn::dataDim_t dim1 = net->input_dim; //input dim
|
||||
tk::dnn::dataDim_t dim1 = net->input_dim; //input dim
|
||||
printCenteredTitle(" CUDNN inference ", '=', 30); {
|
||||
dim1.print();
|
||||
TIMER_START
|
||||
@@ -80,5 +79,4 @@ int main() {
|
||||
ret_cudnn_tensorrt |= checkResult(odim, cudnn_out[i], rt_out[i]) == 0 ? 0 : ERROR_CUDNNvsTENSORRT;
|
||||
}
|
||||
return ret_cudnn | ret_tensorrt | ret_cudnn_tensorrt;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user