From commits-return-22241-archive-asf-public=cust-asf.ponee.io@mxnet.incubator.apache.org Thu Feb 1 19:52:27 2018 Return-Path: X-Original-To: archive-asf-public@eu.ponee.io Delivered-To: archive-asf-public@eu.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by mx-eu-01.ponee.io (Postfix) with ESMTP id C005618066D for ; Thu, 1 Feb 2018 19:52:27 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id ADF44160C35; Thu, 1 Feb 2018 18:52:27 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 01754160C44 for ; Thu, 1 Feb 2018 19:52:26 +0100 (CET) Received: (qmail 65936 invoked by uid 500); 1 Feb 2018 18:52:26 -0000 Mailing-List: contact commits-help@mxnet.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@mxnet.incubator.apache.org Delivered-To: mailing list commits@mxnet.incubator.apache.org Received: (qmail 65904 invoked by uid 99); 1 Feb 2018 18:52:26 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Feb 2018 18:52:26 +0000 From: GitBox To: commits@mxnet.apache.org Subject: [GitHub] larroy commented on a change in pull request #8582: Yolo2 operator Message-ID: <151751114559.26461.2497840296200069040.gitbox@gitbox.apache.org> larroy commented on a change in pull request #8582: Yolo2 operator URL: https://github.com/apache/incubator-mxnet/pull/8582#discussion_r165448626 ########## File path: src/operator/contrib/yolo_output-inl.h ########## @@ -0,0 +1,703 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/*! + * \file yolo_output-inl.h + * \brief yolo-v2 output layer, v1 to be added + * \author Joshua Zhang +*/ +#ifndef MXNET_OPERATOR_CONTRIB_YOLO_OUTPUT_INL_H_ +#define MXNET_OPERATOR_CONTRIB_YOLO_OUTPUT_INL_H_ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../operator_common.h" +#include "../mshadow_op.h" +#include "../mxnet_op.h" +#include "../tensor/sort_op.h" + +namespace mxnet { +namespace op { +namespace yolo2out_enum { +enum Yolo2OutputOpInputs {kData, kLabel}; +enum Yolo2OutputOpOutputs {kOut, kTemp, kCopy}; +enum Yolo2OutputOpAuxiliary {kCounter}; +enum Yolo2OutputOpResource {kTempSpace}; +} // namespace yolo2out_enum + +struct Yolo2OutputParam : public dmlc::Parameter { + int num_class; + int num_anchor; + float overlap_thresh; + float object_grad_scale; + float background_grad_scale; + float class_grad_scale; + float coord_grad_scale; + nnvm::Tuple anchors; + int warmup_samples; + float warmup_grad_scale; + float nms_threshold; + int nms_topk; + bool force_suppress; + DMLC_DECLARE_PARAMETER(Yolo2OutputParam) { + DMLC_DECLARE_FIELD(num_class).set_lower_bound(1) + .describe("Number of object classes."); + DMLC_DECLARE_FIELD(num_anchor).set_default(5) + .set_lower_bound(1) + .describe("Number of anchors."); + DMLC_DECLARE_FIELD(overlap_thresh).set_default(0.6) + .describe("Positive overlap threshold."); + DMLC_DECLARE_FIELD(object_grad_scale).set_default(1.0) + .describe("Gradient scale for positive objects."); + DMLC_DECLARE_FIELD(background_grad_scale).set_default(1.0) + .describe("Gradient scale for background."); + DMLC_DECLARE_FIELD(class_grad_scale).set_default(1.0) + .describe("Gradient scale for positive objects."); + DMLC_DECLARE_FIELD(coord_grad_scale).set_default(1.0) + .describe("Gradient scale for box offsets."); + DMLC_DECLARE_FIELD(anchors) + .set_default({1.08f, 1.19f, 3.42f, 4.41f, 6.63f, 11.38f, 9.42f, 5.11f, 16.62f, 10.52f}) + .describe("Predefined anchor box widths and heights."); + DMLC_DECLARE_FIELD(warmup_samples).set_default(12800) + .describe("Number of images to warm up towards averaging position for box " + "predictions when starting a new training. "); + DMLC_DECLARE_FIELD(warmup_grad_scale).set_default(0.01) + .describe("Gradient scale for non-critical anchors during warm-up stage."); + DMLC_DECLARE_FIELD(nms_threshold).set_default(0.5f) + .describe("Non-maximum suppression threshold."); + DMLC_DECLARE_FIELD(force_suppress).set_default(false) + .describe("Suppress all detections regardless of class_id."); + DMLC_DECLARE_FIELD(nms_topk).set_default(-1) + .describe("Keep maximum top k detections before nms, -1 for no limit."); + } +}; // struct Yolo2OutputParam + +template +MSHADOW_XINLINE DType Intersect(DType l1, DType r1, DType l2, DType r2) { + DType left = l1 > l2 ? l1 : l2; + DType right = r1 < r2 ? r1 : r2; + DType w = right - left; + return w > 0 ? w : DType(0); +} + +template +MSHADOW_XINLINE DType Area(DType l1, DType t1, DType r1, DType b1) { + DType width = r1 - l1; + DType height = b1 - t1; + if (width <= 0 || height <= 0) return DType(0); + return width * height; +} + +template +MSHADOW_XINLINE DType IOU(DType l1, DType t1, DType r1, DType b1, Review comment: I would add a comment describing what's Intersection Over Union, to help readers. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: users@infra.apache.org With regards, Apache Git Services