From 3ed46b52dbe48fbf0496bc70ac15fe7177b118bd Mon Sep 17 00:00:00 2001 From: linghu8812 Date: Thu, 19 Nov 2020 00:37:20 +0800 Subject: [PATCH] add support export yolov4-tiny onnx and tensorrt inference --- Yolov4/README.md | 29 +- Yolov4/Yolov4.cpp | 20 +- Yolov4/Yolov4.h | 5 +- Yolov4/config-tiny.yaml | 13 + Yolov4/config.yaml | 3 +- Yolov4/export_onnx.py | 184 +++++++-- Yolov4/yolov3-spp.cfg | 822 ++++++++++++++++++++++++++++++++++++++++ Yolov4/yolov3-tiny.cfg | 182 +++++++++ Yolov4/yolov3.cfg | 789 ++++++++++++++++++++++++++++++++++++++ Yolov4/yolov4-tiny.cfg | 281 ++++++++++++++ yolov5/README.md | 10 +- 11 files changed, 2286 insertions(+), 52 deletions(-) create mode 100755 Yolov4/config-tiny.yaml create mode 100644 Yolov4/yolov3-spp.cfg create mode 100644 Yolov4/yolov3-tiny.cfg create mode 100644 Yolov4/yolov3.cfg create mode 100644 Yolov4/yolov4-tiny.cfg diff --git a/Yolov4/README.md b/Yolov4/README.md index 92a75ff8..e795ca03 100755 --- a/Yolov4/README.md +++ b/Yolov4/README.md @@ -6,9 +6,23 @@ - get YOLOv4 weights from here: [yolov4.weights](https://drive.google.com/open?id=1sWNozS0emz7bmQTUWDLvsubLGnCwUiIS) ## 2.Export ONNX Model +- export yolov4 onnx ``` python3 export_onnx.py ``` +- export yolov4-tiny onnx +``` +python3 export_onnx.py --cfg_file yolov4-tiny.cfg --weights_file yolov4-tiny.weights --output_file yolov4-tiny.onnx --strides 32 16 --neck FPN +``` +- export yolov3, yolov3-spp onnx +``` +python3 export_onnx.py --cfg_file yolov3.cfg --weights_file yolov3.weights --output_file yolov3.onnx --strides 32 16 8 --neck FPN +python3 export_onnx.py --cfg_file yolov3-spp.cfg --weights_file yolov3-spp.weights --output_file yolov3-spp.onnx --strides 32 16 8 --neck FPN +``` +- export yolov3-tiny onnx +``` +python3 export_onnx.py --cfg_file yolov3-tiny.cfg --weights_file yolov3-tiny.weights --output_file yolov3-tiny.onnx --strides 32 16 --neck FPN +``` ## 3.Build Yolov4_trt Project ``` @@ -18,17 +32,14 @@ make -j ``` ## 4.Run Yolov4_trt +- inference with yolov4 ``` ./Yolov4_trt ../config.yaml ../samples ``` +- inference with yolov4-tiny +``` +./Yolov4_trt ../config-tiny.yaml ../samples +``` -## 5.Inference Time Benchmark -model|resolution|darknet|TensorRT| ----|---|---|--- -yolov4|416x416||4.2ms -yolov4|608x608||6.3ms -yolov4-voc_mobilenetv2|416x416||2.2ms -yolov4-voc_mobilenetv2_mish|416x416||2.5ms - -## 6.Results +## 5.Results ![](prediction.jpg) \ No newline at end of file diff --git a/Yolov4/Yolov4.cpp b/Yolov4/Yolov4.cpp index 723fc653..df855b81 100644 --- a/Yolov4/Yolov4.cpp +++ b/Yolov4/Yolov4.cpp @@ -14,15 +14,17 @@ YOLOv4::YOLOv4(const std::string &config_file) { IMAGE_HEIGHT = config["IMAGE_HEIGHT"].as(); obj_threshold = config["obj_threshold"].as(); nms_threshold = config["nms_threshold"].as(); - stride = config["stride"].as>(); + strides = config["strides"].as>(); + num_anchors = config["num_anchors"].as>(); + assert(strides.size() == num_anchors.size()); anchors = config["anchors"].as>>(); - coco_labels = readCOCOLabel(labels_file); - CATEGORY = coco_labels.size(); - grids = { - {3, int(IMAGE_WIDTH / stride[0]), int(IMAGE_HEIGHT / stride[0])}, - {3, int(IMAGE_WIDTH / stride[1]), int(IMAGE_HEIGHT / stride[1])}, - {3, int(IMAGE_WIDTH / stride[2]), int(IMAGE_HEIGHT / stride[2])}, - }; + detect_labels = readCOCOLabel(labels_file); + CATEGORY = detect_labels.size(); + int index = 0; + for (const int &stride : strides) + { + grids.push_back({num_anchors[index], int(IMAGE_WIDTH / stride), int(IMAGE_HEIGHT / stride)}); + } refer_rows = 0; refer_cols = 6; for (const std::vector &grid : grids) { @@ -159,7 +161,7 @@ void YOLOv4::EngineInference(const std::vector &image_list, const i { char t[256]; sprintf(t, "%.2f", rect.prob); - std::string name = coco_labels[rect.classes] + "-" + t; + std::string name = detect_labels[rect.classes] + "-" + t; cv::putText(org_img, name, cv::Point(rect.x - rect.w / 2, rect.y - rect.h / 2 - 5), cv::FONT_HERSHEY_COMPLEX, 0.7, class_colors[rect.classes], 2); cv::Rect rst(rect.x - rect.w / 2, rect.y - rect.h / 2, rect.w, rect.h); cv::rectangle(org_img, rst, class_colors[rect.classes], 2, cv::LINE_8, 0); diff --git a/Yolov4/Yolov4.h b/Yolov4/Yolov4.h index 5eb73916..752c726c 100644 --- a/Yolov4/Yolov4.h +++ b/Yolov4/Yolov4.h @@ -33,7 +33,7 @@ class YOLOv4 std::string onnx_file; std::string engine_file; std::string labels_file; - std::map coco_labels; + std::map detect_labels; int BATCH_SIZE; int INPUT_CHANNEL; int IMAGE_WIDTH; @@ -46,7 +46,8 @@ class YOLOv4 int refer_rows; int refer_cols; cv::Mat refer_matrix; - std::vector stride; + std::vector strides; + std::vector num_anchors; std::vector> anchors; std::vector> grids; std::vector class_colors; diff --git a/Yolov4/config-tiny.yaml b/Yolov4/config-tiny.yaml new file mode 100755 index 00000000..82eb9b90 --- /dev/null +++ b/Yolov4/config-tiny.yaml @@ -0,0 +1,13 @@ +Yolov4: + onnx_file: "../yolov4-tiny.onnx" + engine_file: "../yolov4-tiny.trt" + labels_file: "../coco.names" + BATCH_SIZE: 1 + INPUT_CHANNEL: 3 + IMAGE_WIDTH: 416 + IMAGE_HEIGHT: 416 + obj_threshold: 0.4 + nms_threshold: 0.45 + strides: [16, 32] + num_anchors: [ 3, 3] + anchors: [[ 23, 27], [ 37, 58], [ 81, 82], [ 81, 82], [135, 169], [ 344, 319]] diff --git a/Yolov4/config.yaml b/Yolov4/config.yaml index 542f8eb4..233fa9fe 100755 --- a/Yolov4/config.yaml +++ b/Yolov4/config.yaml @@ -8,5 +8,6 @@ Yolov4: IMAGE_HEIGHT: 608 obj_threshold: 0.4 nms_threshold: 0.45 - stride: [8, 16, 32] + strides: [8, 16, 32] + num_anchors: [3, 3, 3] anchors: [[12, 16], [19, 36], [40, 28], [36, 75], [76, 55], [72, 146], [142, 110], [192, 243], [459, 401]] diff --git a/Yolov4/export_onnx.py b/Yolov4/export_onnx.py index 53e4766c..c75a8ef5 100755 --- a/Yolov4/export_onnx.py +++ b/Yolov4/export_onnx.py @@ -75,7 +75,11 @@ def _next_layer(self, remainder): if remainder.replace(' ', '')[0] == '#': remainder = remainder.split('\n', 1)[1] - layer_param_block, remainder = remainder.split('\n\n', 1) + if '\n\n' in remainder: + layer_param_block, remainder = remainder.split('\n\n', 1) + else: + layer_param_block, remainder = remainder, '' + layer_param_lines = layer_param_block.split('\n')[1:] layer_name = str(self.layer_counter).zfill(3) + '_' + layer_type layer_dict = dict(type=layer_type) @@ -87,10 +91,7 @@ def _next_layer(self, remainder): layer_dict[param_type] = param_value else: for param_line in layer_param_lines: - if 'class' in param_line: - param_type, param_value = self._parse_params(param_line) - layer_dict[param_type] = param_value - if 'num' in param_line: + if 'class' in param_line or 'num' in param_line or 'mask' in param_line: param_type, param_value = self._parse_params(param_line) layer_dict[param_type] = param_value self.layer_counter += 1 @@ -117,6 +118,8 @@ def _parse_params(self, param_line): param_value_raw[1:].isdigit() if condition_param_value_positive or condition_param_value_negative: param_value = int(param_value_raw) + elif ',' in param_value_raw: + param_value = param_value_raw.split(',') else: param_value = float(param_value_raw) else: @@ -245,6 +248,86 @@ def generate_param_name(self): return param_name +class StartParams(object): + # Helper class to store the scale parameter for an Resize node. + + def __init__(self, node_name, value): + """Constructor based on the base node name (e.g. 86_Resize), + and the value of the scale input tensor. + + Keyword arguments: + node_name -- base name of this YOLO Resize layer + value -- the value of the scale input to the Resize layer as numpy array + """ + self.node_name = node_name + self.value = value + + def generate_param_name(self): + """Generates the scale parameter name for the Resize node.""" + param_name = self.node_name + '_' + "start" + return param_name + + +class EndParams(object): + # Helper class to store the scale parameter for an Resize node. + + def __init__(self, node_name, value): + """Constructor based on the base node name (e.g. 86_Resize), + and the value of the scale input tensor. + + Keyword arguments: + node_name -- base name of this YOLO Resize layer + value -- the value of the scale input to the Resize layer as numpy array + """ + self.node_name = node_name + self.value = value + + def generate_param_name(self): + """Generates the scale parameter name for the Resize node.""" + param_name = self.node_name + '_' + "end" + return param_name + + +class AxesParams(object): + # Helper class to store the scale parameter for an Resize node. + + def __init__(self, node_name, value): + """Constructor based on the base node name (e.g. 86_Resize), + and the value of the scale input tensor. + + Keyword arguments: + node_name -- base name of this YOLO Resize layer + value -- the value of the scale input to the Resize layer as numpy array + """ + self.node_name = node_name + self.value = value + + def generate_param_name(self): + """Generates the scale parameter name for the Resize node.""" + param_name = self.node_name + '_' + "axes" + return param_name + + +class StepParams(object): + # Helper class to store the scale parameter for an Resize node. + + def __init__(self, node_name, value): + """Constructor based on the base node name (e.g. 86_Resize), + and the value of the scale input tensor. + + Keyword arguments: + node_name -- base name of this YOLO Resize layer + value -- the value of the scale input to the Resize layer as numpy array + """ + self.node_name = node_name + self.value = value + + def generate_param_name(self): + """Generates the scale parameter name for the Resize node.""" + param_name = self.node_name + '_' + "step" + return param_name + + class WeightLoader(object): """Helper class used for loading the serialized weights of a binary file stream and returning the initializers and the input tensors required for populating @@ -300,6 +383,21 @@ def load_reshape_scales(self, reshape_params): inputs.append(scale_input) return initializer, inputs + def load_slice_params(self, slice_params): + initializer = list() + inputs = list() + for params in slice_params: + name = params.generate_param_name() + shape = params.value.shape + data = params.value + data_init = helper.make_tensor( + name, TensorProto.INT64, shape, data) + data_input = helper.make_tensor_value_info( + name, TensorProto.INT64, shape) + initializer.append(data_init) + inputs.append(data_input) + return initializer, inputs + def load_conv_weights(self, conv_params): """Returns the initializers with weights from the weights file and the input tensors of a convolutional layer for all corresponding ONNX nodes. @@ -421,6 +519,7 @@ def build_onnx_graph( self, layer_configs, weights_file_path, + neck, verbose=True): """Iterate over all layer configs (parsed from the DarkNet representation of YOLOv3-608), create an ONNX graph, populate it with weights from the weights @@ -447,9 +546,12 @@ def build_onnx_graph( output_dims = [self.batch_size, ] + \ self.output_tensors[tensor_name] layer_name, layer_dict = tensor_name, {'output_dims': output_dims} - transpose_name = self._make_transpose_node(layer_name, layer_dict) + transpose_name = self._make_transpose_node(layer_name, layer_dict, len(self.output_tensors)) transposes.append(transpose_name) + if neck == 'FPN': + transposes = transposes[::-1] + output_name = 'ouputs' route_node = helper.make_node( 'Concat', @@ -484,6 +586,10 @@ def build_onnx_graph( initializer_layer, inputs_layer = weight_loader.load_reshape_scales(params) initializer.extend(initializer_layer) inputs.extend(inputs_layer) + elif 'slice' in layer_type: + initializer_layer, inputs_layer = weight_loader.load_slice_params(params) + initializer.extend(initializer_layer) + inputs.extend(inputs_layer) del weight_loader self.graph_def = helper.make_graph( nodes=self._nodes, @@ -758,6 +864,40 @@ def _make_route_node(self, layer_name, layer_dict): self.major_node_specs = self.major_node_specs[:split_index] layer_name = None channels = None + elif 'groups' in layer_dict: + assert layer_dict['groups'] == 2 + assert layer_dict['group_id'] == 1 + inputs = [input_node_specs.name] + slice_name = layer_name + '_slice' + channels = input_node_specs.channels + start = np.array([channels // 2]).astype(np.int64) + start_params = StartParams(layer_name, start) + self.param_dict[slice_name] = [start_params] + param_name = start_params.generate_param_name() + inputs.append(param_name) + end = np.array([channels]).astype(np.int64) + end_params = EndParams(layer_name, end) + self.param_dict[slice_name].append(end_params) + param_name = end_params.generate_param_name() + inputs.append(param_name) + axes = np.array([1]).astype(np.int64) + axes_params = AxesParams(layer_name, axes) + self.param_dict[slice_name].append(axes_params) + param_name = axes_params.generate_param_name() + inputs.append(param_name) + steps = np.array([1]).astype(np.int64) + step_params = StepParams(layer_name, steps) + self.param_dict[slice_name].append(step_params) + param_name = step_params.generate_param_name() + inputs.append(param_name) + slice_node = helper.make_node( + 'Slice', + inputs=inputs, + outputs=[layer_name], + name=layer_name, + ) + channels = channels // 2 + self._nodes.append(slice_node) else: inputs = [input_node_specs.name] route_node = helper.make_node( @@ -846,10 +986,10 @@ def _make_maxpool_node(self, layer_name, layer_dict): self._nodes.append(maxpool_node) return layer_name, channels - def _make_transpose_node(self, layer_name, layer_dict): + def _make_transpose_node(self, layer_name, layer_dict, output_len): inputs = [layer_name] reshape_name = layer_name + '_reshape_1' - shape = np.array([layer_dict['output_dims'][0], self.num // 3, self.classes + 5, + shape = np.array([layer_dict['output_dims'][0], self.num // output_len, self.classes + 5, layer_dict['output_dims'][-2], layer_dict['output_dims'][-1]]).astype(np.int64) reshape_params = ReshapeParams(layer_name, shape) self.param_dict[reshape_name] = reshape_params @@ -886,7 +1026,7 @@ def _make_transpose_node(self, layer_name, layer_dict): return output_name -def main(cfg_file='yolov3.cfg', weights_file='yolov3.weights', output_file='yolov3.onnx', neck='FPN'): +def main(cfg_file='yolov3.cfg', weights_file='yolov3.weights', output_file='yolov3.onnx', strides=None, neck='PAN'): cfg_file_path = cfg_file supported_layers = ['net', 'convolutional', 'shortcut', @@ -899,28 +1039,23 @@ def main(cfg_file='yolov3.cfg', weights_file='yolov3.weights', output_file='yolo width = layer_configs['000_net']['width'] height = layer_configs['000_net']['height'] - conv_layers = [] + conv_layers, num_anchors = [], [] for layer_key in layer_configs.keys(): if 'conv' in layer_key: conv_layer = layer_key if 'yolo' in layer_key: yolo_layer = layer_key + num_anchors.append(len(layer_configs[yolo_layer]['mask'])) conv_layers.append(conv_layer) classes = layer_configs[yolo_layer]['classes'] - if neck == 'FPN': - stride = [32, 16, 8] - elif neck == 'PAN': - stride = [8, 16, 32] - else: - print('Neck must be FPN or PAN!') + if not strides: return output_tensor_dims = OrderedDict() - output_tensor_dims[conv_layers[0]] = [(classes + 5) * 3, width // stride[0], height // stride[0]] - output_tensor_dims[conv_layers[1]] = [(classes + 5) * 3, width // stride[1], height // stride[1]] - output_tensor_dims[conv_layers[2]] = [(classes + 5) * 3, width // stride[2], height // stride[2]] + for conv_layer, stride, num_anchor in zip(conv_layers, strides, num_anchors): + output_tensor_dims[conv_layer] = [(classes + 5) * num_anchor, width // stride, height // stride] # Create a GraphBuilderONNX object with the known output tensor dimensions: builder = GraphBuilderONNX(output_tensor_dims) @@ -929,19 +1064,20 @@ def main(cfg_file='yolov3.cfg', weights_file='yolov3.weights', output_file='yolo # Now generate an ONNX graph with weights from the previously parsed layer configurations # and the weights file: - yolov3_model_def = builder.build_onnx_graph( + yolo_model_def = builder.build_onnx_graph( layer_configs=layer_configs, weights_file_path=weights_file_path, + neck=neck, verbose=True) # Once we have the model definition, we do not need the builder anymore: del builder # Perform a sanity check on the ONNX model definition: - onnx.checker.check_model(yolov3_model_def) + onnx.checker.check_model(yolo_model_def) # Serialize the generated ONNX graph to this file: output_file_path = output_file - onnx.save(yolov3_model_def, output_file_path) + onnx.save(yolo_model_def, output_file_path) print('Save ONNX File {} success!'.format(output_file_path)) @@ -950,6 +1086,8 @@ def main(cfg_file='yolov3.cfg', weights_file='yolov3.weights', output_file='yolo parser.add_argument('--cfg_file', type=str, default='yolov4.cfg', help='yolo cfg file') parser.add_argument('--weights_file', type=str, default='yolov4.weights', help='yolo weights file') parser.add_argument('--output_file', type=str, default='yolov4.onnx', help='yolo onnx file') + parser.add_argument('--strides', nargs='+', type=int, default=[8, 16, 32], help='YOLO model cell size') parser.add_argument('--neck', type=str, default='PAN', help='use which kind neck') args = parser.parse_args() - main(cfg_file=args.cfg_file, weights_file=args.weights_file, output_file=args.output_file, neck=args.neck) + main(cfg_file=args.cfg_file, weights_file=args.weights_file, output_file=args.output_file, strides=args.strides, + neck=args.neck) diff --git a/Yolov4/yolov3-spp.cfg b/Yolov4/yolov3-spp.cfg new file mode 100644 index 00000000..4ad2a052 --- /dev/null +++ b/Yolov4/yolov3-spp.cfg @@ -0,0 +1,822 @@ +[net] +# Testing +batch=1 +subdivisions=1 +# Training +# batch=64 +# subdivisions=16 +width=608 +height=608 +channels=3 +momentum=0.9 +decay=0.0005 +angle=0 +saturation = 1.5 +exposure = 1.5 +hue=.1 + +learning_rate=0.001 +burn_in=1000 +max_batches = 500200 +policy=steps +steps=400000,450000 +scales=.1,.1 + +[convolutional] +batch_normalize=1 +filters=32 +size=3 +stride=1 +pad=1 +activation=leaky + +# Downsample + +[convolutional] +batch_normalize=1 +filters=64 +size=3 +stride=2 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=32 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=64 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + +# Downsample + +[convolutional] +batch_normalize=1 +filters=128 +size=3 +stride=2 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=64 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=128 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + +[convolutional] +batch_normalize=1 +filters=64 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=128 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + +# Downsample + +[convolutional] +batch_normalize=1 +filters=256 +size=3 +stride=2 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=128 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=256 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + +[convolutional] +batch_normalize=1 +filters=128 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=256 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + +[convolutional] +batch_normalize=1 +filters=128 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=256 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + +[convolutional] +batch_normalize=1 +filters=128 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=256 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + + +[convolutional] +batch_normalize=1 +filters=128 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=256 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + +[convolutional] +batch_normalize=1 +filters=128 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=256 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + +[convolutional] +batch_normalize=1 +filters=128 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=256 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + +[convolutional] +batch_normalize=1 +filters=128 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=256 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + +# Downsample + +[convolutional] +batch_normalize=1 +filters=512 +size=3 +stride=2 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=256 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=512 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + + +[convolutional] +batch_normalize=1 +filters=256 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=512 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + + +[convolutional] +batch_normalize=1 +filters=256 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=512 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + + +[convolutional] +batch_normalize=1 +filters=256 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=512 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + +[convolutional] +batch_normalize=1 +filters=256 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=512 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + + +[convolutional] +batch_normalize=1 +filters=256 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=512 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + + +[convolutional] +batch_normalize=1 +filters=256 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=512 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + +[convolutional] +batch_normalize=1 +filters=256 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=512 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + +# Downsample + +[convolutional] +batch_normalize=1 +filters=1024 +size=3 +stride=2 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=512 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=1024 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + +[convolutional] +batch_normalize=1 +filters=512 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=1024 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + +[convolutional] +batch_normalize=1 +filters=512 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=1024 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + +[convolutional] +batch_normalize=1 +filters=512 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=1024 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + +###################### + +[convolutional] +batch_normalize=1 +filters=512 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +size=3 +stride=1 +pad=1 +filters=1024 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=512 +size=1 +stride=1 +pad=1 +activation=leaky + +### SPP ### +[maxpool] +stride=1 +size=5 + +[route] +layers=-2 + +[maxpool] +stride=1 +size=9 + +[route] +layers=-4 + +[maxpool] +stride=1 +size=13 + +[route] +layers=-1,-3,-5,-6 + +### End SPP ### + +[convolutional] +batch_normalize=1 +filters=512 +size=1 +stride=1 +pad=1 +activation=leaky + + +[convolutional] +batch_normalize=1 +size=3 +stride=1 +pad=1 +filters=1024 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=512 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +size=3 +stride=1 +pad=1 +filters=1024 +activation=leaky + +[convolutional] +size=1 +stride=1 +pad=1 +filters=255 +activation=linear + + +[yolo] +mask = 6,7,8 +anchors = 10,13, 16,30, 33,23, 30,61, 62,45, 59,119, 116,90, 156,198, 373,326 +classes=80 +num=9 +jitter=.3 +ignore_thresh = .7 +truth_thresh = 1 +random=1 + + +[route] +layers = -4 + +[convolutional] +batch_normalize=1 +filters=256 +size=1 +stride=1 +pad=1 +activation=leaky + +[upsample] +stride=2 + +[route] +layers = -1, 61 + + + +[convolutional] +batch_normalize=1 +filters=256 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +size=3 +stride=1 +pad=1 +filters=512 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=256 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +size=3 +stride=1 +pad=1 +filters=512 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=256 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +size=3 +stride=1 +pad=1 +filters=512 +activation=leaky + +[convolutional] +size=1 +stride=1 +pad=1 +filters=255 +activation=linear + + +[yolo] +mask = 3,4,5 +anchors = 10,13, 16,30, 33,23, 30,61, 62,45, 59,119, 116,90, 156,198, 373,326 +classes=80 +num=9 +jitter=.3 +ignore_thresh = .7 +truth_thresh = 1 +random=1 + + + +[route] +layers = -4 + +[convolutional] +batch_normalize=1 +filters=128 +size=1 +stride=1 +pad=1 +activation=leaky + +[upsample] +stride=2 + +[route] +layers = -1, 36 + + + +[convolutional] +batch_normalize=1 +filters=128 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +size=3 +stride=1 +pad=1 +filters=256 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=128 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +size=3 +stride=1 +pad=1 +filters=256 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=128 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +size=3 +stride=1 +pad=1 +filters=256 +activation=leaky + +[convolutional] +size=1 +stride=1 +pad=1 +filters=255 +activation=linear + + +[yolo] +mask = 0,1,2 +anchors = 10,13, 16,30, 33,23, 30,61, 62,45, 59,119, 116,90, 156,198, 373,326 +classes=80 +num=9 +jitter=.3 +ignore_thresh = .7 +truth_thresh = 1 +random=1 + diff --git a/Yolov4/yolov3-tiny.cfg b/Yolov4/yolov3-tiny.cfg new file mode 100644 index 00000000..cfca3cfa --- /dev/null +++ b/Yolov4/yolov3-tiny.cfg @@ -0,0 +1,182 @@ +[net] +# Testing +batch=1 +subdivisions=1 +# Training +# batch=64 +# subdivisions=2 +width=416 +height=416 +channels=3 +momentum=0.9 +decay=0.0005 +angle=0 +saturation = 1.5 +exposure = 1.5 +hue=.1 + +learning_rate=0.001 +burn_in=1000 +max_batches = 500200 +policy=steps +steps=400000,450000 +scales=.1,.1 + +[convolutional] +batch_normalize=1 +filters=16 +size=3 +stride=1 +pad=1 +activation=leaky + +[maxpool] +size=2 +stride=2 + +[convolutional] +batch_normalize=1 +filters=32 +size=3 +stride=1 +pad=1 +activation=leaky + +[maxpool] +size=2 +stride=2 + +[convolutional] +batch_normalize=1 +filters=64 +size=3 +stride=1 +pad=1 +activation=leaky + +[maxpool] +size=2 +stride=2 + +[convolutional] +batch_normalize=1 +filters=128 +size=3 +stride=1 +pad=1 +activation=leaky + +[maxpool] +size=2 +stride=2 + +[convolutional] +batch_normalize=1 +filters=256 +size=3 +stride=1 +pad=1 +activation=leaky + +[maxpool] +size=2 +stride=2 + +[convolutional] +batch_normalize=1 +filters=512 +size=3 +stride=1 +pad=1 +activation=leaky + +[maxpool] +size=2 +stride=1 + +[convolutional] +batch_normalize=1 +filters=1024 +size=3 +stride=1 +pad=1 +activation=leaky + +########### + +[convolutional] +batch_normalize=1 +filters=256 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=512 +size=3 +stride=1 +pad=1 +activation=leaky + +[convolutional] +size=1 +stride=1 +pad=1 +filters=255 +activation=linear + + + +[yolo] +mask = 3,4,5 +anchors = 10,14, 23,27, 37,58, 81,82, 135,169, 344,319 +classes=80 +num=6 +jitter=.3 +ignore_thresh = .7 +truth_thresh = 1 +random=1 + +[route] +layers = -4 + +[convolutional] +batch_normalize=1 +filters=128 +size=1 +stride=1 +pad=1 +activation=leaky + +[upsample] +stride=2 + +[route] +layers = -1, 8 + +[convolutional] +batch_normalize=1 +filters=256 +size=3 +stride=1 +pad=1 +activation=leaky + +[convolutional] +size=1 +stride=1 +pad=1 +filters=255 +activation=linear + +[yolo] +mask = 0,1,2 +anchors = 10,14, 23,27, 37,58, 81,82, 135,169, 344,319 +classes=80 +num=6 +jitter=.3 +ignore_thresh = .7 +truth_thresh = 1 +random=1 diff --git a/Yolov4/yolov3.cfg b/Yolov4/yolov3.cfg new file mode 100644 index 00000000..c3e26fad --- /dev/null +++ b/Yolov4/yolov3.cfg @@ -0,0 +1,789 @@ +[net] +# Testing +batch=1 +subdivisions=1 +# Training +# batch=64 +# subdivisions=16 +width=608 +height=608 +channels=3 +momentum=0.9 +decay=0.0005 +angle=0 +saturation = 1.5 +exposure = 1.5 +hue=.1 + +learning_rate=0.001 +burn_in=1000 +max_batches = 500200 +policy=steps +steps=400000,450000 +scales=.1,.1 + +[convolutional] +batch_normalize=1 +filters=32 +size=3 +stride=1 +pad=1 +activation=leaky + +# Downsample + +[convolutional] +batch_normalize=1 +filters=64 +size=3 +stride=2 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=32 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=64 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + +# Downsample + +[convolutional] +batch_normalize=1 +filters=128 +size=3 +stride=2 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=64 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=128 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + +[convolutional] +batch_normalize=1 +filters=64 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=128 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + +# Downsample + +[convolutional] +batch_normalize=1 +filters=256 +size=3 +stride=2 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=128 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=256 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + +[convolutional] +batch_normalize=1 +filters=128 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=256 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + +[convolutional] +batch_normalize=1 +filters=128 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=256 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + +[convolutional] +batch_normalize=1 +filters=128 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=256 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + + +[convolutional] +batch_normalize=1 +filters=128 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=256 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + +[convolutional] +batch_normalize=1 +filters=128 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=256 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + +[convolutional] +batch_normalize=1 +filters=128 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=256 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + +[convolutional] +batch_normalize=1 +filters=128 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=256 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + +# Downsample + +[convolutional] +batch_normalize=1 +filters=512 +size=3 +stride=2 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=256 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=512 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + + +[convolutional] +batch_normalize=1 +filters=256 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=512 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + + +[convolutional] +batch_normalize=1 +filters=256 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=512 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + + +[convolutional] +batch_normalize=1 +filters=256 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=512 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + +[convolutional] +batch_normalize=1 +filters=256 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=512 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + + +[convolutional] +batch_normalize=1 +filters=256 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=512 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + + +[convolutional] +batch_normalize=1 +filters=256 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=512 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + +[convolutional] +batch_normalize=1 +filters=256 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=512 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + +# Downsample + +[convolutional] +batch_normalize=1 +filters=1024 +size=3 +stride=2 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=512 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=1024 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + +[convolutional] +batch_normalize=1 +filters=512 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=1024 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + +[convolutional] +batch_normalize=1 +filters=512 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=1024 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + +[convolutional] +batch_normalize=1 +filters=512 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=1024 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + +###################### + +[convolutional] +batch_normalize=1 +filters=512 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +size=3 +stride=1 +pad=1 +filters=1024 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=512 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +size=3 +stride=1 +pad=1 +filters=1024 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=512 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +size=3 +stride=1 +pad=1 +filters=1024 +activation=leaky + +[convolutional] +size=1 +stride=1 +pad=1 +filters=255 +activation=linear + + +[yolo] +mask = 6,7,8 +anchors = 10,13, 16,30, 33,23, 30,61, 62,45, 59,119, 116,90, 156,198, 373,326 +classes=80 +num=9 +jitter=.3 +ignore_thresh = .7 +truth_thresh = 1 +random=1 + + +[route] +layers = -4 + +[convolutional] +batch_normalize=1 +filters=256 +size=1 +stride=1 +pad=1 +activation=leaky + +[upsample] +stride=2 + +[route] +layers = -1, 61 + + + +[convolutional] +batch_normalize=1 +filters=256 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +size=3 +stride=1 +pad=1 +filters=512 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=256 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +size=3 +stride=1 +pad=1 +filters=512 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=256 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +size=3 +stride=1 +pad=1 +filters=512 +activation=leaky + +[convolutional] +size=1 +stride=1 +pad=1 +filters=255 +activation=linear + + +[yolo] +mask = 3,4,5 +anchors = 10,13, 16,30, 33,23, 30,61, 62,45, 59,119, 116,90, 156,198, 373,326 +classes=80 +num=9 +jitter=.3 +ignore_thresh = .7 +truth_thresh = 1 +random=1 + + + +[route] +layers = -4 + +[convolutional] +batch_normalize=1 +filters=128 +size=1 +stride=1 +pad=1 +activation=leaky + +[upsample] +stride=2 + +[route] +layers = -1, 36 + + + +[convolutional] +batch_normalize=1 +filters=128 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +size=3 +stride=1 +pad=1 +filters=256 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=128 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +size=3 +stride=1 +pad=1 +filters=256 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=128 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +size=3 +stride=1 +pad=1 +filters=256 +activation=leaky + +[convolutional] +size=1 +stride=1 +pad=1 +filters=255 +activation=linear + + +[yolo] +mask = 0,1,2 +anchors = 10,13, 16,30, 33,23, 30,61, 62,45, 59,119, 116,90, 156,198, 373,326 +classes=80 +num=9 +jitter=.3 +ignore_thresh = .7 +truth_thresh = 1 +random=1 + diff --git a/Yolov4/yolov4-tiny.cfg b/Yolov4/yolov4-tiny.cfg new file mode 100644 index 00000000..cc2f93b8 --- /dev/null +++ b/Yolov4/yolov4-tiny.cfg @@ -0,0 +1,281 @@ +[net] +# Testing +batch=1 +subdivisions=1 +# Training +# batch=64 +# subdivisions=1 +width=416 +height=416 +channels=3 +momentum=0.9 +decay=0.0005 +angle=0 +saturation = 1.5 +exposure = 1.5 +hue=.1 + +learning_rate=0.00261 +burn_in=1000 +max_batches = 500200 +policy=steps +steps=400000,450000 +scales=.1,.1 + +[convolutional] +batch_normalize=1 +filters=32 +size=3 +stride=2 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=64 +size=3 +stride=2 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=64 +size=3 +stride=1 +pad=1 +activation=leaky + +[route] +layers=-1 +groups=2 +group_id=1 + +[convolutional] +batch_normalize=1 +filters=32 +size=3 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=32 +size=3 +stride=1 +pad=1 +activation=leaky + +[route] +layers = -1,-2 + +[convolutional] +batch_normalize=1 +filters=64 +size=1 +stride=1 +pad=1 +activation=leaky + +[route] +layers = -6,-1 + +[maxpool] +size=2 +stride=2 + +[convolutional] +batch_normalize=1 +filters=128 +size=3 +stride=1 +pad=1 +activation=leaky + +[route] +layers=-1 +groups=2 +group_id=1 + +[convolutional] +batch_normalize=1 +filters=64 +size=3 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=64 +size=3 +stride=1 +pad=1 +activation=leaky + +[route] +layers = -1,-2 + +[convolutional] +batch_normalize=1 +filters=128 +size=1 +stride=1 +pad=1 +activation=leaky + +[route] +layers = -6,-1 + +[maxpool] +size=2 +stride=2 + +[convolutional] +batch_normalize=1 +filters=256 +size=3 +stride=1 +pad=1 +activation=leaky + +[route] +layers=-1 +groups=2 +group_id=1 + +[convolutional] +batch_normalize=1 +filters=128 +size=3 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=128 +size=3 +stride=1 +pad=1 +activation=leaky + +[route] +layers = -1,-2 + +[convolutional] +batch_normalize=1 +filters=256 +size=1 +stride=1 +pad=1 +activation=leaky + +[route] +layers = -6,-1 + +[maxpool] +size=2 +stride=2 + +[convolutional] +batch_normalize=1 +filters=512 +size=3 +stride=1 +pad=1 +activation=leaky + +################################## + +[convolutional] +batch_normalize=1 +filters=256 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=512 +size=3 +stride=1 +pad=1 +activation=leaky + +[convolutional] +size=1 +stride=1 +pad=1 +filters=255 +activation=linear + + + +[yolo] +mask = 3,4,5 +anchors = 10,14, 23,27, 37,58, 81,82, 135,169, 344,319 +classes=80 +num=6 +jitter=.3 +scale_x_y = 1.05 +cls_normalizer=1.0 +iou_normalizer=0.07 +iou_loss=ciou +ignore_thresh = .7 +truth_thresh = 1 +random=0 +resize=1.5 +nms_kind=greedynms +beta_nms=0.6 + +[route] +layers = -4 + +[convolutional] +batch_normalize=1 +filters=128 +size=1 +stride=1 +pad=1 +activation=leaky + +[upsample] +stride=2 + +[route] +layers = -1, 23 + +[convolutional] +batch_normalize=1 +filters=256 +size=3 +stride=1 +pad=1 +activation=leaky + +[convolutional] +size=1 +stride=1 +pad=1 +filters=255 +activation=linear + +[yolo] +mask = 1,2,3 +anchors = 10,14, 23,27, 37,58, 81,82, 135,169, 344,319 +classes=80 +num=6 +jitter=.3 +scale_x_y = 1.05 +cls_normalizer=1.0 +iou_normalizer=0.07 +iou_loss=ciou +ignore_thresh = .7 +truth_thresh = 1 +random=0 +resize=1.5 +nms_kind=greedynms +beta_nms=0.6 diff --git a/yolov5/README.md b/yolov5/README.md index 752d87fa..283db34b 100644 --- a/yolov5/README.md +++ b/yolov5/README.md @@ -23,15 +23,9 @@ cmake .. make -j ``` -## 4.run yolov5_trt +## 4.Run yolov5_trt ``` ./yolov5_trt ../config.yaml ../samples ``` -predict results: +## 5.Results: ![](prediction.jpg) - -## 5.Inference Time Benchmark -model|resolution|PyTorch|TensorRT| ----|---|---|--- -yolov5s|640x640| |2.5ms -yolov5x|640x640| |11.3ms \ No newline at end of file