Added test and helpers for draw_bounding_boxes op both cpu and cuda related.

master
shugeo 2019-10-04 20:46:26 +03:00
parent 8f70b4441f
commit 53a2ebddbe
4 changed files with 78 additions and 7 deletions

View File

@ -21,16 +21,18 @@
#include <op_boilerplate.h> #include <op_boilerplate.h>
#if NOT_EXCLUDED(OP_draw_bounding_boxes) #if NOT_EXCLUDED(OP_draw_bounding_boxes)
//#include <ops/declarable/headers/parity_ops.h> #include <ops/declarable/headers/parity_ops.h>
#include <ops/declarable/CustomOperations.h> #include <ops/declarable/helpers/image_draw_bounding_boxes.h>
namespace nd4j { namespace nd4j {
namespace ops { namespace ops {
OP_IMPL(draw_bounding_boxes, 3, 1, true) { OP_IMPL(draw_bounding_boxes, 3, 1, true) {
auto image = INPUT_VARIABLE(0); auto images = INPUT_VARIABLE(0);
auto boxes = INPUT_VARIABLE(1); auto boxes = INPUT_VARIABLE(1);
auto colors = INPUT_VARIABLE(2); auto colors = INPUT_VARIABLE(2);
auto output = OUTPUT_VARIABLE(0);
helpers::drawBoundingBoxesFunctor(block.launchContext(), images, boxes, colors, output);
return ND4J_STATUS_OK; return ND4J_STATUS_OK;
} }

View File

@ -0,0 +1,33 @@
/*******************************************************************************
* Copyright (c) 2015-2018 Skymind, Inc.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://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.
*
* SPDX-License-Identifier: Apache-2.0
******************************************************************************/
//
// @author sgazeos@gmail.com
//
#include <op_boilerplate.h>
#include <NDArray.h>
namespace nd4j {
namespace ops {
namespace helpers {
void drawBoundingBoxesFunctor(nd4j::LaunchContext * context, NDArray* images, NDArray* boxes, NDArray* colors, NDArray* output) {
}
}
}
}

View File

@ -0,0 +1,33 @@
/*******************************************************************************
* Copyright (c) 2015-2018 Skymind, Inc.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://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.
*
* SPDX-License-Identifier: Apache-2.0
******************************************************************************/
//
// @author sgazeos@gmail.com
//
#include <op_boilerplate.h>
#include <NDArray.h>
namespace nd4j {
namespace ops {
namespace helpers {
void drawBoundingBoxesFunctor(nd4j::LaunchContext * context, NDArray* images, NDArray* boxes, NDArray* colors, NDArray* output) {
}
}
}
}

View File

@ -2045,9 +2045,12 @@ TEST_F(DeclarableOpsTests10, Image_CropAndResize_5) {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
TEST_F(DeclarableOpsTests10, Image_DrawBoundingBoxes_1) { TEST_F(DeclarableOpsTests10, Image_DrawBoundingBoxes_1) {
int axis = 0;
NDArray images = NDArrayFactory::create<float>('c', {2,4,5,3}); NDArray images = NDArrayFactory::create<float>('c', {2,4,5,3});
NDArray boxes = NDArrayFactory::create<float>('c', {2, 2, 4}, {0,0,1,1}); NDArray boxes = NDArrayFactory::create<float>('c', {2, 2, 4}, {
0. , 0. , 1. , 1. , 0.1, 0.2, 0.9, 0.8,
0.3, 0.3, 0.7, 0.7, 0.4, 0.4, 0.6, 0.6
});
NDArray colors = NDArrayFactory::create<float>('c', {2, 3}, {201., 202., 203., 128., 129., 130.}); NDArray colors = NDArrayFactory::create<float>('c', {2, 3}, {201., 202., 203., 128., 129., 130.});
//NDArray<float> ('c', {6}, {0.9f, .75f, .6f, .95f, .5f, .3f}); //NDArray<float> ('c', {6}, {0.9f, .75f, .6f, .95f, .5f, .3f});
@ -2062,7 +2065,7 @@ TEST_F(DeclarableOpsTests10, Image_DrawBoundingBoxes_1) {
91., 92., 93., 201., 202., 203., 201., 202., 203., 100., 101., 102., 103., 104., 105., 91., 92., 93., 201., 202., 203., 201., 202., 203., 100., 101., 102., 103., 104., 105.,
106., 107., 108., 109., 110., 111., 112., 113., 114., 115., 116., 117., 118., 119., 120. 106., 107., 108., 109., 110., 111., 112., 113., 114., 115., 116., 117., 118., 119., 120.
}); });
images.linspace(1.);
nd4j::ops::draw_bounding_boxes op; nd4j::ops::draw_bounding_boxes op;
auto results = op.execute({&images, &boxes, &colors}, {}, {}); auto results = op.execute({&images, &boxes, &colors}, {}, {});