Added service and weight files

This commit is contained in:
yikestone 2019-06-12 11:45:57 +05:30
parent ab43bbcdce
commit febba33f14
18 changed files with 2719 additions and 0 deletions

133
CMakeLists.txt Normal file
View File

@ -0,0 +1,133 @@
cmake_minimum_required(VERSION 2.8.3)
project(openvino_object_detection)
find_package(InferenceEngine 1.5)
find_package(catkin REQUIRED COMPONENTS
message_generation roscpp InferenceEngine sensor_msgs cv_bridge)
if(UNIX OR APPLE)
# Linker flags.
if( ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel")
# GCC specific flags. ICC is compatible with them.
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -z noexecstack -z relro -z now")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -z noexecstack -z relro -z now")
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
# In Clang, -z flags are not compatible, they need to be passed to linker via -Wl.
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now")
endif()
# Compiler flags.
if( ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
# GCC specific flags.
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.9 OR CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 4.9)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIE -fstack-protector-strong")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIE -fstack-protector")
endif()
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
# Clang is compatbile with some of the flags.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIE -fstack-protector")
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel" )
# Same as above, with exception that ICC compilation crashes with -fPIE option, even
# though it uses -pie linker option that require -fPIE during compilation. Checksec
# shows that it generates correct PIE anyway if only -pie is provided.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector")
endif()
# Generic flags.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -fno-operator-names -Wformat -Wformat-security -Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
# Add OpenMP support
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
endif()
# Add x86 intrinsic compiler support
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
execute_process(
COMMAND bash -c "lscpu | grep -qi flags | grep -qi flags | grep -qi f16c"
RESULT_VARIABLE SUPPORT_F16C)
if (SUPPORT_F16C EQUAL 0)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mf16c")
add_definitions(-DSUPPORT_MF16C)
endif()
execute_process(
COMMAND bash -c "lscpu | grep -qi flags | grep -qi flags | grep -qi sse4_1"
RESULT_VARIABLE SUPPORT_SSE41)
if (SUPPORT_SSE41 EQUAL 0)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.1")
endif()
## Generate messages in the 'msg' folder
add_message_files(FILES
Object.msg
)
add_service_files(FILES
Objects.srv
)
generate_messages(DEPENDENCIES
std_msgs
sensor_msgs
)
catkin_package(
CATKIN_DEPENDS
message_runtime
std_msgs
sensor_msgs
)
find_package(OpenCV REQUIRED)
message( ${InferenceEngine_LIBRARIES}
)
include_directories(
include ${catkin_INCLUDE_DIRS}
${InferenceEngine_INCLUDE_DIRS}
${InferenceEngine_INCLUDE_DIRS}/../samples
${InferenceEngine_INCLUDE_DIRS}/../samples/common
${InferenceEngine_DIR}/../src
${InferenceEngine_DIR}/../src/extension
${OpenCV_INCLUDE_DIRS}
)
add_executable(object_detection
src/main.cpp
)
add_executable(object_detection_test
src/test.cpp
)
add_dependencies(object_detection ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
add_dependencies(object_detection_test ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
set_target_properties(object_detection PROPERTIES "CMAKE_CXX_FLAGS" "${CMAKE_CXX_FLAGS} -fPIE"
COMPILE_PDB_NAME object_detection)
target_link_libraries(object_detection
IE::ie_cpu_extension
gflags
dl
pthread
${catkin_LIBRARIES}
${InferenceEngine_LIBRARIES}
${OpenCV_LIBRARIES}
)
target_link_libraries(object_detection_test
${catkin_LIBRARIES}
${OpenCV_LIBRARIES}
)

View File

Binary file not shown.

View File

@ -0,0 +1,80 @@
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

View File

@ -0,0 +1,139 @@
<?xml version="1.0" ?>
<mapping>
<map>
<framework name="detector/yolo-v3-tiny/Conv/LeakyRelu" out_port_id="0"/>
<IR id="2" name="LeakyReLU_859" out_port_id="1"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/Conv/BatchNorm/FusedBatchNorm" out_port_id="0"/>
<IR id="1" name="detector/yolo-v3-tiny/Conv/Conv2D" out_port_id="3"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/Conv_3/LeakyRelu" out_port_id="0"/>
<IR id="11" name="LeakyReLU_858" out_port_id="1"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/pool2_5/MaxPool" out_port_id="0"/>
<IR id="18" name="detector/yolo-v3-tiny/pool2_5/MaxPool" out_port_id="1"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/Conv_1/LeakyRelu" out_port_id="0"/>
<IR id="5" name="LeakyReLU_" out_port_id="1"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/Conv_5/BatchNorm/FusedBatchNorm" out_port_id="0"/>
<IR id="16" name="detector/yolo-v3-tiny/Conv_5/Conv2D" out_port_id="3"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/pool2_3/MaxPool" out_port_id="0"/>
<IR id="12" name="detector/yolo-v3-tiny/pool2_3/MaxPool" out_port_id="1"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/upsampled" out_port_id="0"/>
<IR id="25" name="detector/yolo-v3-tiny/ResizeNearestNeighbor" out_port_id="1"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/ResizeNearestNeighbor" out_port_id="0"/>
<IR id="25" name="detector/yolo-v3-tiny/ResizeNearestNeighbor" out_port_id="1"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/Conv_4/BatchNorm/FusedBatchNorm" out_port_id="0"/>
<IR id="13" name="detector/yolo-v3-tiny/Conv_4/Conv2D" out_port_id="3"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/Conv_9/BiasAdd" out_port_id="0"/>
<IR id="33" name="detector/yolo-v3-tiny/Conv_9/Conv2D" out_port_id="3"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/Conv_2/BatchNorm/FusedBatchNorm" out_port_id="0"/>
<IR id="7" name="detector/yolo-v3-tiny/Conv_2/Conv2D" out_port_id="3"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/pool2_2/MaxPool" out_port_id="0"/>
<IR id="9" name="detector/yolo-v3-tiny/pool2_2/MaxPool" out_port_id="1"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/Conv_5/LeakyRelu" out_port_id="0"/>
<IR id="17" name="LeakyReLU_863" out_port_id="1"/>
</map>
<map>
<framework name="detector/truediv" out_port_id="0"/>
<IR id="0" name="inputs" out_port_id="0"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/Conv_4/LeakyRelu" out_port_id="0"/>
<IR id="14" name="LeakyReLU_856" out_port_id="1"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/pool2_4/MaxPool" out_port_id="0"/>
<IR id="15" name="detector/yolo-v3-tiny/pool2_4/MaxPool" out_port_id="1"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/Conv_1/BatchNorm/FusedBatchNorm" out_port_id="0"/>
<IR id="4" name="detector/yolo-v3-tiny/Conv_1/Conv2D" out_port_id="3"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/Conv_6/BatchNorm/FusedBatchNorm" out_port_id="0"/>
<IR id="19" name="detector/yolo-v3-tiny/Conv_6/Conv2D" out_port_id="3"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/Conv_7/LeakyRelu" out_port_id="0"/>
<IR id="22" name="LeakyReLU_865" out_port_id="1"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/concat_3" out_port_id="0"/>
<IR id="26" name="detector/yolo-v3-tiny/concat_3" out_port_id="2"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/Conv_3/BatchNorm/FusedBatchNorm" out_port_id="0"/>
<IR id="10" name="detector/yolo-v3-tiny/Conv_3/Conv2D" out_port_id="3"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/pool2/MaxPool" out_port_id="0"/>
<IR id="3" name="detector/yolo-v3-tiny/pool2/MaxPool" out_port_id="1"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/Conv_10/BatchNorm/FusedBatchNorm" out_port_id="0"/>
<IR id="23" name="detector/yolo-v3-tiny/Conv_10/Conv2D" out_port_id="3"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/pool2_1/MaxPool" out_port_id="0"/>
<IR id="6" name="detector/yolo-v3-tiny/pool2_1/MaxPool" out_port_id="1"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/Conv_6/LeakyRelu" out_port_id="0"/>
<IR id="20" name="LeakyReLU_860" out_port_id="1"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/Conv_11/LeakyRelu" out_port_id="0"/>
<IR id="28" name="LeakyReLU_857" out_port_id="1"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/Conv_11/BatchNorm/FusedBatchNorm" out_port_id="0"/>
<IR id="27" name="detector/yolo-v3-tiny/Conv_11/Conv2D" out_port_id="3"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/Conv_7/BatchNorm/FusedBatchNorm" out_port_id="0"/>
<IR id="21" name="detector/yolo-v3-tiny/Conv_7/Conv2D" out_port_id="3"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/Conv_12/BiasAdd" out_port_id="0"/>
<IR id="29" name="detector/yolo-v3-tiny/Conv_12/Conv2D" out_port_id="3"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/Conv_2/LeakyRelu" out_port_id="0"/>
<IR id="8" name="LeakyReLU_861" out_port_id="1"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/Conv_8/LeakyRelu" out_port_id="0"/>
<IR id="32" name="LeakyReLU_864" out_port_id="1"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/Conv_10/LeakyRelu" out_port_id="0"/>
<IR id="24" name="LeakyReLU_862" out_port_id="1"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/Conv_8/BatchNorm/FusedBatchNorm" out_port_id="0"/>
<IR id="31" name="detector/yolo-v3-tiny/Conv_8/Conv2D" out_port_id="3"/>
</map>
</mapping>

View File

@ -0,0 +1,783 @@
<?xml version="1.0" ?>
<net batch="1" name="frozen_yolov3-tiny-mine" version="4">
<layers>
<layer id="0" name="inputs" precision="FP16" type="Input">
<output>
<port id="0">
<dim>1</dim>
<dim>3</dim>
<dim>416</dim>
<dim>416</dim>
</port>
</output>
</layer>
<layer id="1" name="detector/yolo-v3-tiny/Conv/Conv2D" precision="FP16" type="Convolution">
<data auto_pad="same_upper" dilations="1,1" group="1" kernel="3,3" output="16" pads_begin="1,1" pads_end="1,1" strides="1,1"/>
<input>
<port id="0">
<dim>1</dim>
<dim>3</dim>
<dim>416</dim>
<dim>416</dim>
</port>
</input>
<output>
<port id="3">
<dim>1</dim>
<dim>16</dim>
<dim>416</dim>
<dim>416</dim>
</port>
</output>
<blobs>
<weights offset="0" size="864"/>
<biases offset="864" size="32"/>
</blobs>
</layer>
<layer id="2" name="LeakyReLU_859" precision="FP16" type="ReLU">
<data negative_slope="0.10000000149011612"/>
<input>
<port id="0">
<dim>1</dim>
<dim>16</dim>
<dim>416</dim>
<dim>416</dim>
</port>
</input>
<output>
<port id="1">
<dim>1</dim>
<dim>16</dim>
<dim>416</dim>
<dim>416</dim>
</port>
</output>
</layer>
<layer id="3" name="detector/yolo-v3-tiny/pool2/MaxPool" precision="FP16" type="Pooling">
<data auto_pad="valid" exclude-pad="true" kernel="2,2" pads_begin="0,0" pads_end="0,0" pool-method="max" strides="2,2"/>
<input>
<port id="0">
<dim>1</dim>
<dim>16</dim>
<dim>416</dim>
<dim>416</dim>
</port>
</input>
<output>
<port id="1">
<dim>1</dim>
<dim>16</dim>
<dim>208</dim>
<dim>208</dim>
</port>
</output>
</layer>
<layer id="4" name="detector/yolo-v3-tiny/Conv_1/Conv2D" precision="FP16" type="Convolution">
<data auto_pad="same_upper" dilations="1,1" group="1" kernel="3,3" output="32" pads_begin="1,1" pads_end="1,1" strides="1,1"/>
<input>
<port id="0">
<dim>1</dim>
<dim>16</dim>
<dim>208</dim>
<dim>208</dim>
</port>
</input>
<output>
<port id="3">
<dim>1</dim>
<dim>32</dim>
<dim>208</dim>
<dim>208</dim>
</port>
</output>
<blobs>
<weights offset="896" size="9216"/>
<biases offset="10112" size="64"/>
</blobs>
</layer>
<layer id="5" name="LeakyReLU_" precision="FP16" type="ReLU">
<data negative_slope="0.10000000149011612"/>
<input>
<port id="0">
<dim>1</dim>
<dim>32</dim>
<dim>208</dim>
<dim>208</dim>
</port>
</input>
<output>
<port id="1">
<dim>1</dim>
<dim>32</dim>
<dim>208</dim>
<dim>208</dim>
</port>
</output>
</layer>
<layer id="6" name="detector/yolo-v3-tiny/pool2_1/MaxPool" precision="FP16" type="Pooling">
<data auto_pad="valid" exclude-pad="true" kernel="2,2" pads_begin="0,0" pads_end="0,0" pool-method="max" strides="2,2"/>
<input>
<port id="0">
<dim>1</dim>
<dim>32</dim>
<dim>208</dim>
<dim>208</dim>
</port>
</input>
<output>
<port id="1">
<dim>1</dim>
<dim>32</dim>
<dim>104</dim>
<dim>104</dim>
</port>
</output>
</layer>
<layer id="7" name="detector/yolo-v3-tiny/Conv_2/Conv2D" precision="FP16" type="Convolution">
<data auto_pad="same_upper" dilations="1,1" group="1" kernel="3,3" output="64" pads_begin="1,1" pads_end="1,1" strides="1,1"/>
<input>
<port id="0">
<dim>1</dim>
<dim>32</dim>
<dim>104</dim>
<dim>104</dim>
</port>
</input>
<output>
<port id="3">
<dim>1</dim>
<dim>64</dim>
<dim>104</dim>
<dim>104</dim>
</port>
</output>
<blobs>
<weights offset="10176" size="36864"/>
<biases offset="47040" size="128"/>
</blobs>
</layer>
<layer id="8" name="LeakyReLU_861" precision="FP16" type="ReLU">
<data negative_slope="0.10000000149011612"/>
<input>
<port id="0">
<dim>1</dim>
<dim>64</dim>
<dim>104</dim>
<dim>104</dim>
</port>
</input>
<output>
<port id="1">
<dim>1</dim>
<dim>64</dim>
<dim>104</dim>
<dim>104</dim>
</port>
</output>
</layer>
<layer id="9" name="detector/yolo-v3-tiny/pool2_2/MaxPool" precision="FP16" type="Pooling">
<data auto_pad="valid" exclude-pad="true" kernel="2,2" pads_begin="0,0" pads_end="0,0" pool-method="max" strides="2,2"/>
<input>
<port id="0">
<dim>1</dim>
<dim>64</dim>
<dim>104</dim>
<dim>104</dim>
</port>
</input>
<output>
<port id="1">
<dim>1</dim>
<dim>64</dim>
<dim>52</dim>
<dim>52</dim>
</port>
</output>
</layer>
<layer id="10" name="detector/yolo-v3-tiny/Conv_3/Conv2D" precision="FP16" type="Convolution">
<data auto_pad="same_upper" dilations="1,1" group="1" kernel="3,3" output="128" pads_begin="1,1" pads_end="1,1" strides="1,1"/>
<input>
<port id="0">
<dim>1</dim>
<dim>64</dim>
<dim>52</dim>
<dim>52</dim>
</port>
</input>
<output>
<port id="3">
<dim>1</dim>
<dim>128</dim>
<dim>52</dim>
<dim>52</dim>
</port>
</output>
<blobs>
<weights offset="47168" size="147456"/>
<biases offset="194624" size="256"/>
</blobs>
</layer>
<layer id="11" name="LeakyReLU_858" precision="FP16" type="ReLU">
<data negative_slope="0.10000000149011612"/>
<input>
<port id="0">
<dim>1</dim>
<dim>128</dim>
<dim>52</dim>
<dim>52</dim>
</port>
</input>
<output>
<port id="1">
<dim>1</dim>
<dim>128</dim>
<dim>52</dim>
<dim>52</dim>
</port>
</output>
</layer>
<layer id="12" name="detector/yolo-v3-tiny/pool2_3/MaxPool" precision="FP16" type="Pooling">
<data auto_pad="valid" exclude-pad="true" kernel="2,2" pads_begin="0,0" pads_end="0,0" pool-method="max" strides="2,2"/>
<input>
<port id="0">
<dim>1</dim>
<dim>128</dim>
<dim>52</dim>
<dim>52</dim>
</port>
</input>
<output>
<port id="1">
<dim>1</dim>
<dim>128</dim>
<dim>26</dim>
<dim>26</dim>
</port>
</output>
</layer>
<layer id="13" name="detector/yolo-v3-tiny/Conv_4/Conv2D" precision="FP16" type="Convolution">
<data auto_pad="same_upper" dilations="1,1" group="1" kernel="3,3" output="256" pads_begin="1,1" pads_end="1,1" strides="1,1"/>
<input>
<port id="0">
<dim>1</dim>
<dim>128</dim>
<dim>26</dim>
<dim>26</dim>
</port>
</input>
<output>
<port id="3">
<dim>1</dim>
<dim>256</dim>
<dim>26</dim>
<dim>26</dim>
</port>
</output>
<blobs>
<weights offset="194880" size="589824"/>
<biases offset="784704" size="512"/>
</blobs>
</layer>
<layer id="14" name="LeakyReLU_856" precision="FP16" type="ReLU">
<data negative_slope="0.10000000149011612"/>
<input>
<port id="0">
<dim>1</dim>
<dim>256</dim>
<dim>26</dim>
<dim>26</dim>
</port>
</input>
<output>
<port id="1">
<dim>1</dim>
<dim>256</dim>
<dim>26</dim>
<dim>26</dim>
</port>
</output>
</layer>
<layer id="15" name="detector/yolo-v3-tiny/pool2_4/MaxPool" precision="FP16" type="Pooling">
<data auto_pad="valid" exclude-pad="true" kernel="2,2" pads_begin="0,0" pads_end="0,0" pool-method="max" strides="2,2"/>
<input>
<port id="0">
<dim>1</dim>
<dim>256</dim>
<dim>26</dim>
<dim>26</dim>
</port>
</input>
<output>
<port id="1">
<dim>1</dim>
<dim>256</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</output>
</layer>
<layer id="16" name="detector/yolo-v3-tiny/Conv_5/Conv2D" precision="FP16" type="Convolution">
<data auto_pad="same_upper" dilations="1,1" group="1" kernel="3,3" output="512" pads_begin="1,1" pads_end="1,1" strides="1,1"/>
<input>
<port id="0">
<dim>1</dim>
<dim>256</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</input>
<output>
<port id="3">
<dim>1</dim>
<dim>512</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</output>
<blobs>
<weights offset="785216" size="2359296"/>
<biases offset="3144512" size="1024"/>
</blobs>
</layer>
<layer id="17" name="LeakyReLU_863" precision="FP16" type="ReLU">
<data negative_slope="0.10000000149011612"/>
<input>
<port id="0">
<dim>1</dim>
<dim>512</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</input>
<output>
<port id="1">
<dim>1</dim>
<dim>512</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</output>
</layer>
<layer id="18" name="detector/yolo-v3-tiny/pool2_5/MaxPool" precision="FP16" type="Pooling">
<data auto_pad="same_upper" exclude-pad="true" kernel="2,2" pads_begin="0,0" pads_end="1,1" pool-method="max" strides="1,1"/>
<input>
<port id="0">
<dim>1</dim>
<dim>512</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</input>
<output>
<port id="1">
<dim>1</dim>
<dim>512</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</output>
</layer>
<layer id="19" name="detector/yolo-v3-tiny/Conv_6/Conv2D" precision="FP16" type="Convolution">
<data auto_pad="same_upper" dilations="1,1" group="1" kernel="3,3" output="1024" pads_begin="1,1" pads_end="1,1" strides="1,1"/>
<input>
<port id="0">
<dim>1</dim>
<dim>512</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</input>
<output>
<port id="3">
<dim>1</dim>
<dim>1024</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</output>
<blobs>
<weights offset="3145536" size="9437184"/>
<biases offset="12582720" size="2048"/>
</blobs>
</layer>
<layer id="20" name="LeakyReLU_860" precision="FP16" type="ReLU">
<data negative_slope="0.10000000149011612"/>
<input>
<port id="0">
<dim>1</dim>
<dim>1024</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</input>
<output>
<port id="1">
<dim>1</dim>
<dim>1024</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</output>
</layer>
<layer id="21" name="detector/yolo-v3-tiny/Conv_7/Conv2D" precision="FP16" type="Convolution">
<data auto_pad="same_upper" dilations="1,1" group="1" kernel="1,1" output="256" pads_begin="0,0" pads_end="0,0" strides="1,1"/>
<input>
<port id="0">
<dim>1</dim>
<dim>1024</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</input>
<output>
<port id="3">
<dim>1</dim>
<dim>256</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</output>
<blobs>
<weights offset="12584768" size="524288"/>
<biases offset="13109056" size="512"/>
</blobs>
</layer>
<layer id="22" name="LeakyReLU_865" precision="FP16" type="ReLU">
<data negative_slope="0.10000000149011612"/>
<input>
<port id="0">
<dim>1</dim>
<dim>256</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</input>
<output>
<port id="1">
<dim>1</dim>
<dim>256</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</output>
</layer>
<layer id="23" name="detector/yolo-v3-tiny/Conv_10/Conv2D" precision="FP16" type="Convolution">
<data auto_pad="same_upper" dilations="1,1" group="1" kernel="1,1" output="128" pads_begin="0,0" pads_end="0,0" strides="1,1"/>
<input>
<port id="0">
<dim>1</dim>
<dim>256</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</input>
<output>
<port id="3">
<dim>1</dim>
<dim>128</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</output>
<blobs>
<weights offset="13109568" size="65536"/>
<biases offset="13175104" size="256"/>
</blobs>
</layer>
<layer id="24" name="LeakyReLU_862" precision="FP16" type="ReLU">
<data negative_slope="0.10000000149011612"/>
<input>
<port id="0">
<dim>1</dim>
<dim>128</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</input>
<output>
<port id="1">
<dim>1</dim>
<dim>128</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</output>
</layer>
<layer id="25" name="detector/yolo-v3-tiny/ResizeNearestNeighbor" precision="FP16" type="Resample">
<data antialias="0" factor="2.0" type="caffe.ResampleParameter.NEAREST"/>
<input>
<port id="0">
<dim>1</dim>
<dim>128</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</input>
<output>
<port id="1">
<dim>1</dim>
<dim>128</dim>
<dim>26</dim>
<dim>26</dim>
</port>
</output>
</layer>
<layer id="26" name="detector/yolo-v3-tiny/concat_3" precision="FP16" type="Concat">
<data axis="1"/>
<input>
<port id="0">
<dim>1</dim>
<dim>128</dim>
<dim>26</dim>
<dim>26</dim>
</port>
<port id="1">
<dim>1</dim>
<dim>256</dim>
<dim>26</dim>
<dim>26</dim>
</port>
</input>
<output>
<port id="2">
<dim>1</dim>
<dim>384</dim>
<dim>26</dim>
<dim>26</dim>
</port>
</output>
</layer>
<layer id="27" name="detector/yolo-v3-tiny/Conv_11/Conv2D" precision="FP16" type="Convolution">
<data auto_pad="same_upper" dilations="1,1" group="1" kernel="3,3" output="256" pads_begin="1,1" pads_end="1,1" strides="1,1"/>
<input>
<port id="0">
<dim>1</dim>
<dim>384</dim>
<dim>26</dim>
<dim>26</dim>
</port>
</input>
<output>
<port id="3">
<dim>1</dim>
<dim>256</dim>
<dim>26</dim>
<dim>26</dim>
</port>
</output>
<blobs>
<weights offset="13175360" size="1769472"/>
<biases offset="14944832" size="512"/>
</blobs>
</layer>
<layer id="28" name="LeakyReLU_857" precision="FP16" type="ReLU">
<data negative_slope="0.10000000149011612"/>
<input>
<port id="0">
<dim>1</dim>
<dim>256</dim>
<dim>26</dim>
<dim>26</dim>
</port>
</input>
<output>
<port id="1">
<dim>1</dim>
<dim>256</dim>
<dim>26</dim>
<dim>26</dim>
</port>
</output>
</layer>
<layer id="29" name="detector/yolo-v3-tiny/Conv_12/Conv2D" precision="FP16" type="Convolution">
<data auto_pad="same_upper" dilations="1,1" group="1" kernel="1,1" output="255" pads_begin="0,0" pads_end="0,0" strides="1,1"/>
<input>
<port id="0">
<dim>1</dim>
<dim>256</dim>
<dim>26</dim>
<dim>26</dim>
</port>
</input>
<output>
<port id="3">
<dim>1</dim>
<dim>255</dim>
<dim>26</dim>
<dim>26</dim>
</port>
</output>
<blobs>
<weights offset="14945344" size="130560"/>
<biases offset="15075904" size="510"/>
</blobs>
</layer>
<layer id="30" name="detector/yolo-v3-tiny/Conv_12/BiasAdd/YoloRegion" precision="FP16" type="RegionYolo">
<data anchors="10,14,23,27,37,58,81,82,135,169,344,319" axis="1" classes="80" coords="4" do_softmax="0" end_axis="3" mask="0,1,2" num="6"/>
<input>
<port id="0">
<dim>1</dim>
<dim>255</dim>
<dim>26</dim>
<dim>26</dim>
</port>
</input>
<output>
<port id="1">
<dim>1</dim>
<dim>255</dim>
<dim>26</dim>
<dim>26</dim>
</port>
</output>
</layer>
<layer id="31" name="detector/yolo-v3-tiny/Conv_8/Conv2D" precision="FP16" type="Convolution">
<data auto_pad="same_upper" dilations="1,1" group="1" kernel="3,3" output="512" pads_begin="1,1" pads_end="1,1" strides="1,1"/>
<input>
<port id="0">
<dim>1</dim>
<dim>256</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</input>
<output>
<port id="3">
<dim>1</dim>
<dim>512</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</output>
<blobs>
<weights offset="15076414" size="2359296"/>
<biases offset="17435710" size="1024"/>
</blobs>
</layer>
<layer id="32" name="LeakyReLU_864" precision="FP16" type="ReLU">
<data negative_slope="0.10000000149011612"/>
<input>
<port id="0">
<dim>1</dim>
<dim>512</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</input>
<output>
<port id="1">
<dim>1</dim>
<dim>512</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</output>
</layer>
<layer id="33" name="detector/yolo-v3-tiny/Conv_9/Conv2D" precision="FP16" type="Convolution">
<data auto_pad="same_upper" dilations="1,1" group="1" kernel="1,1" output="255" pads_begin="0,0" pads_end="0,0" strides="1,1"/>
<input>
<port id="0">
<dim>1</dim>
<dim>512</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</input>
<output>
<port id="3">
<dim>1</dim>
<dim>255</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</output>
<blobs>
<weights offset="17436734" size="261120"/>
<biases offset="17697854" size="510"/>
</blobs>
</layer>
<layer id="34" name="detector/yolo-v3-tiny/Conv_9/BiasAdd/YoloRegion" precision="FP16" type="RegionYolo">
<data anchors="10,14,23,27,37,58,81,82,135,169,344,319" axis="1" classes="80" coords="4" do_softmax="0" end_axis="3" mask="0,1,2" num="6"/>
<input>
<port id="0">
<dim>1</dim>
<dim>255</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</input>
<output>
<port id="1">
<dim>1</dim>
<dim>255</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</output>
</layer>
</layers>
<edges>
<edge from-layer="0" from-port="0" to-layer="1" to-port="0"/>
<edge from-layer="1" from-port="3" to-layer="2" to-port="0"/>
<edge from-layer="2" from-port="1" to-layer="3" to-port="0"/>
<edge from-layer="3" from-port="1" to-layer="4" to-port="0"/>
<edge from-layer="4" from-port="3" to-layer="5" to-port="0"/>
<edge from-layer="5" from-port="1" to-layer="6" to-port="0"/>
<edge from-layer="6" from-port="1" to-layer="7" to-port="0"/>
<edge from-layer="7" from-port="3" to-layer="8" to-port="0"/>
<edge from-layer="8" from-port="1" to-layer="9" to-port="0"/>
<edge from-layer="9" from-port="1" to-layer="10" to-port="0"/>
<edge from-layer="10" from-port="3" to-layer="11" to-port="0"/>
<edge from-layer="11" from-port="1" to-layer="12" to-port="0"/>
<edge from-layer="12" from-port="1" to-layer="13" to-port="0"/>
<edge from-layer="13" from-port="3" to-layer="14" to-port="0"/>
<edge from-layer="14" from-port="1" to-layer="15" to-port="0"/>
<edge from-layer="15" from-port="1" to-layer="16" to-port="0"/>
<edge from-layer="16" from-port="3" to-layer="17" to-port="0"/>
<edge from-layer="17" from-port="1" to-layer="18" to-port="0"/>
<edge from-layer="18" from-port="1" to-layer="19" to-port="0"/>
<edge from-layer="19" from-port="3" to-layer="20" to-port="0"/>
<edge from-layer="20" from-port="1" to-layer="21" to-port="0"/>
<edge from-layer="21" from-port="3" to-layer="22" to-port="0"/>
<edge from-layer="22" from-port="1" to-layer="23" to-port="0"/>
<edge from-layer="23" from-port="3" to-layer="24" to-port="0"/>
<edge from-layer="24" from-port="1" to-layer="25" to-port="0"/>
<edge from-layer="25" from-port="1" to-layer="26" to-port="0"/>
<edge from-layer="14" from-port="1" to-layer="26" to-port="1"/>
<edge from-layer="26" from-port="2" to-layer="27" to-port="0"/>
<edge from-layer="27" from-port="3" to-layer="28" to-port="0"/>
<edge from-layer="28" from-port="1" to-layer="29" to-port="0"/>
<edge from-layer="29" from-port="3" to-layer="30" to-port="0"/>
<edge from-layer="22" from-port="1" to-layer="31" to-port="0"/>
<edge from-layer="31" from-port="3" to-layer="32" to-port="0"/>
<edge from-layer="32" from-port="1" to-layer="33" to-port="0"/>
<edge from-layer="33" from-port="3" to-layer="34" to-port="0"/>
</edges>
<meta_data>
<MO_version value="1.5.12.49d067a0"/>
<cli_parameters>
<data_type value="FP16"/>
<disable_fusing value="False"/>
<disable_gfusing value="False"/>
<disable_nhwc_to_nchw value="False"/>
<disable_resnet_optimization value="False"/>
<extensions value="DIR"/>
<framework value="tf"/>
<generate_deprecated_IR_V2 value="False"/>
<input_model value="DIR/frozen_yolov3-tiny-mine.pb"/>
<input_model_is_text value="False"/>
<input_shape value="[1,416,416,3]"/>
<log_level value="ERROR"/>
<mean_values value="()"/>
<move_to_preprocess value="False"/>
<offload_unsupported_operations_to_tf value="False"/>
<output_dir value="DIR"/>
<reverse_input_channels value="False"/>
<scale_values value="()"/>
<silent value="False"/>
<tensorflow_use_custom_operations_config value="DIR/yolo_v3_tiny_changed.json"/>
<version value="False"/>
<unset unset_cli_parameters="batch, finegrain_fusing, freeze_placeholder_with_value, input, input_checkpoint, input_meta_graph, model_name, output, saved_model_dir, saved_model_tags, scale, tensorboard_logdir, tensorflow_custom_layer_libraries, tensorflow_custom_operations_config_update, tensorflow_object_detection_api_pipeline_config, tensorflow_operation_patterns, tensorflow_subgraph_patterns"/>
</cli_parameters>
</meta_data>
</net>

View File

Binary file not shown.

View File

@ -0,0 +1,80 @@
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

View File

@ -0,0 +1,139 @@
<?xml version="1.0" ?>
<mapping>
<map>
<framework name="detector/yolo-v3-tiny/Conv_4/LeakyRelu" out_port_id="0"/>
<IR id="14" name="LeakyReLU_863" out_port_id="1"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/Conv_1/LeakyRelu" out_port_id="0"/>
<IR id="5" name="LeakyReLU_865" out_port_id="1"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/pool2_1/MaxPool" out_port_id="0"/>
<IR id="6" name="detector/yolo-v3-tiny/pool2_1/MaxPool" out_port_id="1"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/Conv_2/BatchNorm/FusedBatchNorm" out_port_id="0"/>
<IR id="7" name="detector/yolo-v3-tiny/Conv_2/Conv2D" out_port_id="3"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/Conv_1/BatchNorm/FusedBatchNorm" out_port_id="0"/>
<IR id="4" name="detector/yolo-v3-tiny/Conv_1/Conv2D" out_port_id="3"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/Conv_8/LeakyRelu" out_port_id="0"/>
<IR id="32" name="LeakyReLU_864" out_port_id="1"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/Conv_6/LeakyRelu" out_port_id="0"/>
<IR id="20" name="LeakyReLU_856" out_port_id="1"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/Conv_9/BiasAdd" out_port_id="0"/>
<IR id="33" name="detector/yolo-v3-tiny/Conv_9/Conv2D" out_port_id="3"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/pool2_4/MaxPool" out_port_id="0"/>
<IR id="15" name="detector/yolo-v3-tiny/pool2_4/MaxPool" out_port_id="1"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/pool2_2/MaxPool" out_port_id="0"/>
<IR id="9" name="detector/yolo-v3-tiny/pool2_2/MaxPool" out_port_id="1"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/Conv_6/BatchNorm/FusedBatchNorm" out_port_id="0"/>
<IR id="19" name="detector/yolo-v3-tiny/Conv_6/Conv2D" out_port_id="3"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/Conv/BatchNorm/FusedBatchNorm" out_port_id="0"/>
<IR id="1" name="detector/yolo-v3-tiny/Conv/Conv2D" out_port_id="3"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/Conv_3/BatchNorm/FusedBatchNorm" out_port_id="0"/>
<IR id="10" name="detector/yolo-v3-tiny/Conv_3/Conv2D" out_port_id="3"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/Conv_7/LeakyRelu" out_port_id="0"/>
<IR id="22" name="LeakyReLU_861" out_port_id="1"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/Conv_3/LeakyRelu" out_port_id="0"/>
<IR id="11" name="LeakyReLU_859" out_port_id="1"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/Conv_8/BatchNorm/FusedBatchNorm" out_port_id="0"/>
<IR id="31" name="detector/yolo-v3-tiny/Conv_8/Conv2D" out_port_id="3"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/Conv_11/LeakyRelu" out_port_id="0"/>
<IR id="28" name="LeakyReLU_860" out_port_id="1"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/Conv/LeakyRelu" out_port_id="0"/>
<IR id="2" name="LeakyReLU_" out_port_id="1"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/Conv_4/BatchNorm/FusedBatchNorm" out_port_id="0"/>
<IR id="13" name="detector/yolo-v3-tiny/Conv_4/Conv2D" out_port_id="3"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/Conv_10/BatchNorm/FusedBatchNorm" out_port_id="0"/>
<IR id="23" name="detector/yolo-v3-tiny/Conv_10/Conv2D" out_port_id="3"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/upsampled" out_port_id="0"/>
<IR id="25" name="detector/yolo-v3-tiny/ResizeNearestNeighbor" out_port_id="1"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/ResizeNearestNeighbor" out_port_id="0"/>
<IR id="25" name="detector/yolo-v3-tiny/ResizeNearestNeighbor" out_port_id="1"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/Conv_12/BiasAdd" out_port_id="0"/>
<IR id="29" name="detector/yolo-v3-tiny/Conv_12/Conv2D" out_port_id="3"/>
</map>
<map>
<framework name="detector/truediv" out_port_id="0"/>
<IR id="0" name="inputs" out_port_id="0"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/Conv_5/LeakyRelu" out_port_id="0"/>
<IR id="17" name="LeakyReLU_862" out_port_id="1"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/Conv_10/LeakyRelu" out_port_id="0"/>
<IR id="24" name="LeakyReLU_857" out_port_id="1"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/Conv_2/LeakyRelu" out_port_id="0"/>
<IR id="8" name="LeakyReLU_858" out_port_id="1"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/Conv_11/BatchNorm/FusedBatchNorm" out_port_id="0"/>
<IR id="27" name="detector/yolo-v3-tiny/Conv_11/Conv2D" out_port_id="3"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/Conv_5/BatchNorm/FusedBatchNorm" out_port_id="0"/>
<IR id="16" name="detector/yolo-v3-tiny/Conv_5/Conv2D" out_port_id="3"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/pool2/MaxPool" out_port_id="0"/>
<IR id="3" name="detector/yolo-v3-tiny/pool2/MaxPool" out_port_id="1"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/Conv_7/BatchNorm/FusedBatchNorm" out_port_id="0"/>
<IR id="21" name="detector/yolo-v3-tiny/Conv_7/Conv2D" out_port_id="3"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/pool2_5/MaxPool" out_port_id="0"/>
<IR id="18" name="detector/yolo-v3-tiny/pool2_5/MaxPool" out_port_id="1"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/pool2_3/MaxPool" out_port_id="0"/>
<IR id="12" name="detector/yolo-v3-tiny/pool2_3/MaxPool" out_port_id="1"/>
</map>
<map>
<framework name="detector/yolo-v3-tiny/concat_3" out_port_id="0"/>
<IR id="26" name="detector/yolo-v3-tiny/concat_3" out_port_id="2"/>
</map>
</mapping>

View File

@ -0,0 +1,783 @@
<?xml version="1.0" ?>
<net batch="1" name="frozen_yolov3-tiny-mine" version="4">
<layers>
<layer id="0" name="inputs" precision="FP32" type="Input">
<output>
<port id="0">
<dim>1</dim>
<dim>3</dim>
<dim>416</dim>
<dim>416</dim>
</port>
</output>
</layer>
<layer id="1" name="detector/yolo-v3-tiny/Conv/Conv2D" precision="FP32" type="Convolution">
<data auto_pad="same_upper" dilations="1,1" group="1" kernel="3,3" output="16" pads_begin="1,1" pads_end="1,1" strides="1,1"/>
<input>
<port id="0">
<dim>1</dim>
<dim>3</dim>
<dim>416</dim>
<dim>416</dim>
</port>
</input>
<output>
<port id="3">
<dim>1</dim>
<dim>16</dim>
<dim>416</dim>
<dim>416</dim>
</port>
</output>
<blobs>
<weights offset="0" size="1728"/>
<biases offset="1728" size="64"/>
</blobs>
</layer>
<layer id="2" name="LeakyReLU_" precision="FP32" type="ReLU">
<data negative_slope="0.10000000149011612"/>
<input>
<port id="0">
<dim>1</dim>
<dim>16</dim>
<dim>416</dim>
<dim>416</dim>
</port>
</input>
<output>
<port id="1">
<dim>1</dim>
<dim>16</dim>
<dim>416</dim>
<dim>416</dim>
</port>
</output>
</layer>
<layer id="3" name="detector/yolo-v3-tiny/pool2/MaxPool" precision="FP32" type="Pooling">
<data auto_pad="valid" exclude-pad="true" kernel="2,2" pads_begin="0,0" pads_end="0,0" pool-method="max" strides="2,2"/>
<input>
<port id="0">
<dim>1</dim>
<dim>16</dim>
<dim>416</dim>
<dim>416</dim>
</port>
</input>
<output>
<port id="1">
<dim>1</dim>
<dim>16</dim>
<dim>208</dim>
<dim>208</dim>
</port>
</output>
</layer>
<layer id="4" name="detector/yolo-v3-tiny/Conv_1/Conv2D" precision="FP32" type="Convolution">
<data auto_pad="same_upper" dilations="1,1" group="1" kernel="3,3" output="32" pads_begin="1,1" pads_end="1,1" strides="1,1"/>
<input>
<port id="0">
<dim>1</dim>
<dim>16</dim>
<dim>208</dim>
<dim>208</dim>
</port>
</input>
<output>
<port id="3">
<dim>1</dim>
<dim>32</dim>
<dim>208</dim>
<dim>208</dim>
</port>
</output>
<blobs>
<weights offset="1792" size="18432"/>
<biases offset="20224" size="128"/>
</blobs>
</layer>
<layer id="5" name="LeakyReLU_865" precision="FP32" type="ReLU">
<data negative_slope="0.10000000149011612"/>
<input>
<port id="0">
<dim>1</dim>
<dim>32</dim>
<dim>208</dim>
<dim>208</dim>
</port>
</input>
<output>
<port id="1">
<dim>1</dim>
<dim>32</dim>
<dim>208</dim>
<dim>208</dim>
</port>
</output>
</layer>
<layer id="6" name="detector/yolo-v3-tiny/pool2_1/MaxPool" precision="FP32" type="Pooling">
<data auto_pad="valid" exclude-pad="true" kernel="2,2" pads_begin="0,0" pads_end="0,0" pool-method="max" strides="2,2"/>
<input>
<port id="0">
<dim>1</dim>
<dim>32</dim>
<dim>208</dim>
<dim>208</dim>
</port>
</input>
<output>
<port id="1">
<dim>1</dim>
<dim>32</dim>
<dim>104</dim>
<dim>104</dim>
</port>
</output>
</layer>
<layer id="7" name="detector/yolo-v3-tiny/Conv_2/Conv2D" precision="FP32" type="Convolution">
<data auto_pad="same_upper" dilations="1,1" group="1" kernel="3,3" output="64" pads_begin="1,1" pads_end="1,1" strides="1,1"/>
<input>
<port id="0">
<dim>1</dim>
<dim>32</dim>
<dim>104</dim>
<dim>104</dim>
</port>
</input>
<output>
<port id="3">
<dim>1</dim>
<dim>64</dim>
<dim>104</dim>
<dim>104</dim>
</port>
</output>
<blobs>
<weights offset="20352" size="73728"/>
<biases offset="94080" size="256"/>
</blobs>
</layer>
<layer id="8" name="LeakyReLU_858" precision="FP32" type="ReLU">
<data negative_slope="0.10000000149011612"/>
<input>
<port id="0">
<dim>1</dim>
<dim>64</dim>
<dim>104</dim>
<dim>104</dim>
</port>
</input>
<output>
<port id="1">
<dim>1</dim>
<dim>64</dim>
<dim>104</dim>
<dim>104</dim>
</port>
</output>
</layer>
<layer id="9" name="detector/yolo-v3-tiny/pool2_2/MaxPool" precision="FP32" type="Pooling">
<data auto_pad="valid" exclude-pad="true" kernel="2,2" pads_begin="0,0" pads_end="0,0" pool-method="max" strides="2,2"/>
<input>
<port id="0">
<dim>1</dim>
<dim>64</dim>
<dim>104</dim>
<dim>104</dim>
</port>
</input>
<output>
<port id="1">
<dim>1</dim>
<dim>64</dim>
<dim>52</dim>
<dim>52</dim>
</port>
</output>
</layer>
<layer id="10" name="detector/yolo-v3-tiny/Conv_3/Conv2D" precision="FP32" type="Convolution">
<data auto_pad="same_upper" dilations="1,1" group="1" kernel="3,3" output="128" pads_begin="1,1" pads_end="1,1" strides="1,1"/>
<input>
<port id="0">
<dim>1</dim>
<dim>64</dim>
<dim>52</dim>
<dim>52</dim>
</port>
</input>
<output>
<port id="3">
<dim>1</dim>
<dim>128</dim>
<dim>52</dim>
<dim>52</dim>
</port>
</output>
<blobs>
<weights offset="94336" size="294912"/>
<biases offset="389248" size="512"/>
</blobs>
</layer>
<layer id="11" name="LeakyReLU_859" precision="FP32" type="ReLU">
<data negative_slope="0.10000000149011612"/>
<input>
<port id="0">
<dim>1</dim>
<dim>128</dim>
<dim>52</dim>
<dim>52</dim>
</port>
</input>
<output>
<port id="1">
<dim>1</dim>
<dim>128</dim>
<dim>52</dim>
<dim>52</dim>
</port>
</output>
</layer>
<layer id="12" name="detector/yolo-v3-tiny/pool2_3/MaxPool" precision="FP32" type="Pooling">
<data auto_pad="valid" exclude-pad="true" kernel="2,2" pads_begin="0,0" pads_end="0,0" pool-method="max" strides="2,2"/>
<input>
<port id="0">
<dim>1</dim>
<dim>128</dim>
<dim>52</dim>
<dim>52</dim>
</port>
</input>
<output>
<port id="1">
<dim>1</dim>
<dim>128</dim>
<dim>26</dim>
<dim>26</dim>
</port>
</output>
</layer>
<layer id="13" name="detector/yolo-v3-tiny/Conv_4/Conv2D" precision="FP32" type="Convolution">
<data auto_pad="same_upper" dilations="1,1" group="1" kernel="3,3" output="256" pads_begin="1,1" pads_end="1,1" strides="1,1"/>
<input>
<port id="0">
<dim>1</dim>
<dim>128</dim>
<dim>26</dim>
<dim>26</dim>
</port>
</input>
<output>
<port id="3">
<dim>1</dim>
<dim>256</dim>
<dim>26</dim>
<dim>26</dim>
</port>
</output>
<blobs>
<weights offset="389760" size="1179648"/>
<biases offset="1569408" size="1024"/>
</blobs>
</layer>
<layer id="14" name="LeakyReLU_863" precision="FP32" type="ReLU">
<data negative_slope="0.10000000149011612"/>
<input>
<port id="0">
<dim>1</dim>
<dim>256</dim>
<dim>26</dim>
<dim>26</dim>
</port>
</input>
<output>
<port id="1">
<dim>1</dim>
<dim>256</dim>
<dim>26</dim>
<dim>26</dim>
</port>
</output>
</layer>
<layer id="15" name="detector/yolo-v3-tiny/pool2_4/MaxPool" precision="FP32" type="Pooling">
<data auto_pad="valid" exclude-pad="true" kernel="2,2" pads_begin="0,0" pads_end="0,0" pool-method="max" strides="2,2"/>
<input>
<port id="0">
<dim>1</dim>
<dim>256</dim>
<dim>26</dim>
<dim>26</dim>
</port>
</input>
<output>
<port id="1">
<dim>1</dim>
<dim>256</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</output>
</layer>
<layer id="16" name="detector/yolo-v3-tiny/Conv_5/Conv2D" precision="FP32" type="Convolution">
<data auto_pad="same_upper" dilations="1,1" group="1" kernel="3,3" output="512" pads_begin="1,1" pads_end="1,1" strides="1,1"/>
<input>
<port id="0">
<dim>1</dim>
<dim>256</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</input>
<output>
<port id="3">
<dim>1</dim>
<dim>512</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</output>
<blobs>
<weights offset="1570432" size="4718592"/>
<biases offset="6289024" size="2048"/>
</blobs>
</layer>
<layer id="17" name="LeakyReLU_862" precision="FP32" type="ReLU">
<data negative_slope="0.10000000149011612"/>
<input>
<port id="0">
<dim>1</dim>
<dim>512</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</input>
<output>
<port id="1">
<dim>1</dim>
<dim>512</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</output>
</layer>
<layer id="18" name="detector/yolo-v3-tiny/pool2_5/MaxPool" precision="FP32" type="Pooling">
<data auto_pad="same_upper" exclude-pad="true" kernel="2,2" pads_begin="0,0" pads_end="1,1" pool-method="max" strides="1,1"/>
<input>
<port id="0">
<dim>1</dim>
<dim>512</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</input>
<output>
<port id="1">
<dim>1</dim>
<dim>512</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</output>
</layer>
<layer id="19" name="detector/yolo-v3-tiny/Conv_6/Conv2D" precision="FP32" type="Convolution">
<data auto_pad="same_upper" dilations="1,1" group="1" kernel="3,3" output="1024" pads_begin="1,1" pads_end="1,1" strides="1,1"/>
<input>
<port id="0">
<dim>1</dim>
<dim>512</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</input>
<output>
<port id="3">
<dim>1</dim>
<dim>1024</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</output>
<blobs>
<weights offset="6291072" size="18874368"/>
<biases offset="25165440" size="4096"/>
</blobs>
</layer>
<layer id="20" name="LeakyReLU_856" precision="FP32" type="ReLU">
<data negative_slope="0.10000000149011612"/>
<input>
<port id="0">
<dim>1</dim>
<dim>1024</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</input>
<output>
<port id="1">
<dim>1</dim>
<dim>1024</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</output>
</layer>
<layer id="21" name="detector/yolo-v3-tiny/Conv_7/Conv2D" precision="FP32" type="Convolution">
<data auto_pad="same_upper" dilations="1,1" group="1" kernel="1,1" output="256" pads_begin="0,0" pads_end="0,0" strides="1,1"/>
<input>
<port id="0">
<dim>1</dim>
<dim>1024</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</input>
<output>
<port id="3">
<dim>1</dim>
<dim>256</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</output>
<blobs>
<weights offset="25169536" size="1048576"/>
<biases offset="26218112" size="1024"/>
</blobs>
</layer>
<layer id="22" name="LeakyReLU_861" precision="FP32" type="ReLU">
<data negative_slope="0.10000000149011612"/>
<input>
<port id="0">
<dim>1</dim>
<dim>256</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</input>
<output>
<port id="1">
<dim>1</dim>
<dim>256</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</output>
</layer>
<layer id="23" name="detector/yolo-v3-tiny/Conv_10/Conv2D" precision="FP32" type="Convolution">
<data auto_pad="same_upper" dilations="1,1" group="1" kernel="1,1" output="128" pads_begin="0,0" pads_end="0,0" strides="1,1"/>
<input>
<port id="0">
<dim>1</dim>
<dim>256</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</input>
<output>
<port id="3">
<dim>1</dim>
<dim>128</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</output>
<blobs>
<weights offset="26219136" size="131072"/>
<biases offset="26350208" size="512"/>
</blobs>
</layer>
<layer id="24" name="LeakyReLU_857" precision="FP32" type="ReLU">
<data negative_slope="0.10000000149011612"/>
<input>
<port id="0">
<dim>1</dim>
<dim>128</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</input>
<output>
<port id="1">
<dim>1</dim>
<dim>128</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</output>
</layer>
<layer id="25" name="detector/yolo-v3-tiny/ResizeNearestNeighbor" precision="FP32" type="Resample">
<data antialias="0" factor="2.0" type="caffe.ResampleParameter.NEAREST"/>
<input>
<port id="0">
<dim>1</dim>
<dim>128</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</input>
<output>
<port id="1">
<dim>1</dim>
<dim>128</dim>
<dim>26</dim>
<dim>26</dim>
</port>
</output>
</layer>
<layer id="26" name="detector/yolo-v3-tiny/concat_3" precision="FP32" type="Concat">
<data axis="1"/>
<input>
<port id="0">
<dim>1</dim>
<dim>128</dim>
<dim>26</dim>
<dim>26</dim>
</port>
<port id="1">
<dim>1</dim>
<dim>256</dim>
<dim>26</dim>
<dim>26</dim>
</port>
</input>
<output>
<port id="2">
<dim>1</dim>
<dim>384</dim>
<dim>26</dim>
<dim>26</dim>
</port>
</output>
</layer>
<layer id="27" name="detector/yolo-v3-tiny/Conv_11/Conv2D" precision="FP32" type="Convolution">
<data auto_pad="same_upper" dilations="1,1" group="1" kernel="3,3" output="256" pads_begin="1,1" pads_end="1,1" strides="1,1"/>
<input>
<port id="0">
<dim>1</dim>
<dim>384</dim>
<dim>26</dim>
<dim>26</dim>
</port>
</input>
<output>
<port id="3">
<dim>1</dim>
<dim>256</dim>
<dim>26</dim>
<dim>26</dim>
</port>
</output>
<blobs>
<weights offset="26350720" size="3538944"/>
<biases offset="29889664" size="1024"/>
</blobs>
</layer>
<layer id="28" name="LeakyReLU_860" precision="FP32" type="ReLU">
<data negative_slope="0.10000000149011612"/>
<input>
<port id="0">
<dim>1</dim>
<dim>256</dim>
<dim>26</dim>
<dim>26</dim>
</port>
</input>
<output>
<port id="1">
<dim>1</dim>
<dim>256</dim>
<dim>26</dim>
<dim>26</dim>
</port>
</output>
</layer>
<layer id="29" name="detector/yolo-v3-tiny/Conv_12/Conv2D" precision="FP32" type="Convolution">
<data auto_pad="same_upper" dilations="1,1" group="1" kernel="1,1" output="255" pads_begin="0,0" pads_end="0,0" strides="1,1"/>
<input>
<port id="0">
<dim>1</dim>
<dim>256</dim>
<dim>26</dim>
<dim>26</dim>
</port>
</input>
<output>
<port id="3">
<dim>1</dim>
<dim>255</dim>
<dim>26</dim>
<dim>26</dim>
</port>
</output>
<blobs>
<weights offset="29890688" size="261120"/>
<biases offset="30151808" size="1020"/>
</blobs>
</layer>
<layer id="30" name="detector/yolo-v3-tiny/Conv_12/BiasAdd/YoloRegion" precision="FP32" type="RegionYolo">
<data anchors="10,14,23,27,37,58,81,82,135,169,344,319" axis="1" classes="80" coords="4" do_softmax="0" end_axis="3" mask="0,1,2" num="6"/>
<input>
<port id="0">
<dim>1</dim>
<dim>255</dim>
<dim>26</dim>
<dim>26</dim>
</port>
</input>
<output>
<port id="1">
<dim>1</dim>
<dim>255</dim>
<dim>26</dim>
<dim>26</dim>
</port>
</output>
</layer>
<layer id="31" name="detector/yolo-v3-tiny/Conv_8/Conv2D" precision="FP32" type="Convolution">
<data auto_pad="same_upper" dilations="1,1" group="1" kernel="3,3" output="512" pads_begin="1,1" pads_end="1,1" strides="1,1"/>
<input>
<port id="0">
<dim>1</dim>
<dim>256</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</input>
<output>
<port id="3">
<dim>1</dim>
<dim>512</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</output>
<blobs>
<weights offset="30152828" size="4718592"/>
<biases offset="34871420" size="2048"/>
</blobs>
</layer>
<layer id="32" name="LeakyReLU_864" precision="FP32" type="ReLU">
<data negative_slope="0.10000000149011612"/>
<input>
<port id="0">
<dim>1</dim>
<dim>512</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</input>
<output>
<port id="1">
<dim>1</dim>
<dim>512</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</output>
</layer>
<layer id="33" name="detector/yolo-v3-tiny/Conv_9/Conv2D" precision="FP32" type="Convolution">
<data auto_pad="same_upper" dilations="1,1" group="1" kernel="1,1" output="255" pads_begin="0,0" pads_end="0,0" strides="1,1"/>
<input>
<port id="0">
<dim>1</dim>
<dim>512</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</input>
<output>
<port id="3">
<dim>1</dim>
<dim>255</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</output>
<blobs>
<weights offset="34873468" size="522240"/>
<biases offset="35395708" size="1020"/>
</blobs>
</layer>
<layer id="34" name="detector/yolo-v3-tiny/Conv_9/BiasAdd/YoloRegion" precision="FP32" type="RegionYolo">
<data anchors="10,14,23,27,37,58,81,82,135,169,344,319" axis="1" classes="80" coords="4" do_softmax="0" end_axis="3" mask="0,1,2" num="6"/>
<input>
<port id="0">
<dim>1</dim>
<dim>255</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</input>
<output>
<port id="1">
<dim>1</dim>
<dim>255</dim>
<dim>13</dim>
<dim>13</dim>
</port>
</output>
</layer>
</layers>
<edges>
<edge from-layer="0" from-port="0" to-layer="1" to-port="0"/>
<edge from-layer="1" from-port="3" to-layer="2" to-port="0"/>
<edge from-layer="2" from-port="1" to-layer="3" to-port="0"/>
<edge from-layer="3" from-port="1" to-layer="4" to-port="0"/>
<edge from-layer="4" from-port="3" to-layer="5" to-port="0"/>
<edge from-layer="5" from-port="1" to-layer="6" to-port="0"/>
<edge from-layer="6" from-port="1" to-layer="7" to-port="0"/>
<edge from-layer="7" from-port="3" to-layer="8" to-port="0"/>
<edge from-layer="8" from-port="1" to-layer="9" to-port="0"/>
<edge from-layer="9" from-port="1" to-layer="10" to-port="0"/>
<edge from-layer="10" from-port="3" to-layer="11" to-port="0"/>
<edge from-layer="11" from-port="1" to-layer="12" to-port="0"/>
<edge from-layer="12" from-port="1" to-layer="13" to-port="0"/>
<edge from-layer="13" from-port="3" to-layer="14" to-port="0"/>
<edge from-layer="14" from-port="1" to-layer="15" to-port="0"/>
<edge from-layer="15" from-port="1" to-layer="16" to-port="0"/>
<edge from-layer="16" from-port="3" to-layer="17" to-port="0"/>
<edge from-layer="17" from-port="1" to-layer="18" to-port="0"/>
<edge from-layer="18" from-port="1" to-layer="19" to-port="0"/>
<edge from-layer="19" from-port="3" to-layer="20" to-port="0"/>
<edge from-layer="20" from-port="1" to-layer="21" to-port="0"/>
<edge from-layer="21" from-port="3" to-layer="22" to-port="0"/>
<edge from-layer="22" from-port="1" to-layer="23" to-port="0"/>
<edge from-layer="23" from-port="3" to-layer="24" to-port="0"/>
<edge from-layer="24" from-port="1" to-layer="25" to-port="0"/>
<edge from-layer="25" from-port="1" to-layer="26" to-port="0"/>
<edge from-layer="14" from-port="1" to-layer="26" to-port="1"/>
<edge from-layer="26" from-port="2" to-layer="27" to-port="0"/>
<edge from-layer="27" from-port="3" to-layer="28" to-port="0"/>
<edge from-layer="28" from-port="1" to-layer="29" to-port="0"/>
<edge from-layer="29" from-port="3" to-layer="30" to-port="0"/>
<edge from-layer="22" from-port="1" to-layer="31" to-port="0"/>
<edge from-layer="31" from-port="3" to-layer="32" to-port="0"/>
<edge from-layer="32" from-port="1" to-layer="33" to-port="0"/>
<edge from-layer="33" from-port="3" to-layer="34" to-port="0"/>
</edges>
<meta_data>
<MO_version value="1.5.12.49d067a0"/>
<cli_parameters>
<data_type value="FP32"/>
<disable_fusing value="False"/>
<disable_gfusing value="False"/>
<disable_nhwc_to_nchw value="False"/>
<disable_resnet_optimization value="False"/>
<extensions value="DIR"/>
<framework value="tf"/>
<generate_deprecated_IR_V2 value="False"/>
<input_model value="DIR/frozen_yolov3-tiny-mine.pb"/>
<input_model_is_text value="False"/>
<input_shape value="[1,416,416,3]"/>
<log_level value="ERROR"/>
<mean_values value="()"/>
<move_to_preprocess value="False"/>
<offload_unsupported_operations_to_tf value="False"/>
<output_dir value="DIR"/>
<reverse_input_channels value="False"/>
<scale_values value="()"/>
<silent value="False"/>
<tensorflow_use_custom_operations_config value="DIR/yolo_v3_tiny_changed.json"/>
<version value="False"/>
<unset unset_cli_parameters="batch, finegrain_fusing, freeze_placeholder_with_value, input, input_checkpoint, input_meta_graph, model_name, output, saved_model_dir, saved_model_tags, scale, tensorboard_logdir, tensorflow_custom_layer_libraries, tensorflow_custom_operations_config_update, tensorflow_object_detection_api_pipeline_config, tensorflow_operation_patterns, tensorflow_subgraph_patterns"/>
</cli_parameters>
</meta_data>
</net>

View File

@ -0,0 +1,9 @@
<launch>
<node name="object_detection" pkg="openvino_object_detection" type="object_detection">
<param name="target" value="CPU"/>
<param name="model" value="$(find openvino_object_detection)/irmodels/tiny-YoloV3/FP32/frozen_yolov3-tiny-mine.xml"/>
<param name="width" value="648"/>
<param name="height" value="488"/>
</node>
</launch>

16
msg/Object.msg Normal file
View File

@ -0,0 +1,16 @@
string label
#confidence of result
float32 confidence
#normalized value of box center point coordinate x
float32 x
#normalized value of box center point coordinate y
float32 y
#normalized value of box height
float32 h
#normalized value of box width
float32 w

33
package.xml Normal file
View File

@ -0,0 +1,33 @@
<?xml version="1.0"?>
<package format="2">
<name>openvino_object_detection</name>
<version>1.0.1</version>
<description>The openvino package for tiny yolov3 object detection</description>
<maintainer email="rishabh_kundu@rediffmail.com">Rishabh Kundu</maintainer>
<license>MIT</license>
<buildtool_depend>catkin</buildtool_depend>
<buildtool_depend>genmsg</buildtool_depend>
<build_depend>roscpp</build_depend>
<build_depend>OpenCV</build_depend>
<build_depend>message_generation</build_depend>
<build_depend>InferenceEngine</build_depend>
<build_depend>sensor_msgs</build_depend>
<build_export_depend>roscpp</build_export_depend>
<build_export_depend>OpenCV</build_export_depend>
<build_export_depend>InferenceEngine</build_export_depend>
<build_export_depend>sensor_msgs</build_export_depend>
<exec_depend>roscpp</exec_depend>
<exec_depend>OpenCV</exec_depend>
<exec_depend>InferenceEngine</exec_depend>
<exec_depend>sensor_msgs</exec_depend>
<exec_depend>std_msgs</exec_depend>
<build_export_depend>message_generation</build_export_depend>
<exec_depend>message_runtime</exec_depend>
</package>

250
src/main.cpp Normal file
View File

@ -0,0 +1,250 @@
// Copyright (C) 2018 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
/**
* \brief The entry point for the Inference Engine object_detection demo
* application \file object_detection_demo_yolov3_async/main.cpp \example
* object_detection_demo_yolov3_async/main.cpp
*/
#include "object_detection_demo_yolov3_async.hpp"
InferRequest::Ptr async_infer_request_curr;
std::string inputName;
CNNNetReader netReader;
OutputsDataMap outputInf;
bool auto_resize;
InputsDataMap inputInf;
int width;
int height;
std::vector<std::string> labels;
typedef std::chrono::duration<double, std::ratio<1, 1000>> ms;
bool getObjects(openvino_object_detection::Objects::Request &req,
openvino_object_detection::Objects::Response &res) {
auto t = std::chrono::high_resolution_clock::now();
cv::Mat frame = cv_bridge::toCvCopy(req.img, "bgr8")->image;
FrameToBlob(frame, async_infer_request_curr, inputName, auto_resize);
async_infer_request_curr->StartAsync();
if (OK ==
async_infer_request_curr->Wait(IInferRequest::WaitMode::RESULT_READY)) {
// ---------------------------Processing output
// blobs-------------------------------------------------- Processing
// results of the CURRENT request
unsigned long resized_im_h = inputInf.begin()->second.get()->getDims()[0];
unsigned long resized_im_w = inputInf.begin()->second.get()->getDims()[1];
std::vector<DetectionObject> objects;
// Parsing outputs
for (auto &output : outputInf) {
auto output_name = output.first;
// slog::info << "output_name = " + output_name << slog::endl;
CNNLayerPtr layer =
netReader.getNetwork().getLayerByName(output_name.c_str());
Blob::Ptr blob = async_infer_request_curr->GetBlob(output_name);
ParseYOLOV3Output(layer, blob, resized_im_h, resized_im_w, height, width,
req.t, objects);
}
// Filtering overlapping boxes
std::sort(objects.begin(), objects.end());
for (int i = 0; i < objects.size(); ++i) {
if (objects[i].confidence == 0)
continue;
for (int j = i + 1; j < objects.size(); ++j) {
if (IntersectionOverUnion(objects[i], objects[j]) >= req.iou_t) {
objects[j].confidence = 0;
}
// if (objects[j].confidence == 1) {
// objects[j].confidence = 0;
//}
}
}
res.len = 0;
for (auto &object : objects) {
if (object.confidence < req.t)
continue;
openvino_object_detection::Object tmp;
tmp.confidence = object.confidence;
tmp.label = labels[object.class_id];
tmp.x = (object.xmin + object.xmax) / 2.0;
tmp.y = (object.ymin + object.ymax) / 2.0;
tmp.w = object.xmax - object.xmin;
tmp.h = object.ymax - object.ymin;
res.objects.push_back(tmp);
res.len++;
}
}
res.ms = std::chrono::duration_cast<ms>(
std::chrono::high_resolution_clock::now() - t)
.count();
return true;
}
int main(int argc, char *argv[]) {
ros::init(argc, argv, "object_detection");
ros::NodeHandle n;
ros::ServiceServer conf_service =
n.advertiseService("tiny_yolov3", getObjects);
std::string dev;
std::string def = "CPU";
n.param("/object_detection/target", dev, def);
n.param("/object_detection/width", width, 648);
n.param("/object_detection/height", height, 488);
auto_resize = n.hasParam("/object_detection/auto_resize");
std::cout << dev.c_str() << std::endl;
try {
/** This demo covers a certain topology and cannot be generalized for any
* object detection **/
std::cout << "InferenceEngine: " << GetInferenceEngineVersion()
<< std::endl;
// -----------------------------------------------------------------------------------------------------
// --------------------------- 1. Load Plugin for inference engine
// -------------------------------------
slog::info << "Loading plugin" << slog::endl;
InferencePlugin plugin =
PluginDispatcher({"../lib", ""}).getPluginByDevice(dev.c_str());
printPluginVersion(plugin, std::cout);
/**Loading extensions to the plugin **/
/** Loading default extensions **/
if (dev == "CPU") {
/**
* cpu_extensions library is compiled from the "extension" folder
*containing custom CPU layer implementations.
**/
plugin.AddExtension(std::make_shared<Extensions::Cpu::CpuExtensions>());
}
if (n.hasParam("/object_detection/l")) {
std::string l_flags;
n.getParam("/object_detection/l", l_flags);
// CPU extensions are loaded as a shared library and passed as a pointer
// to the base extension
IExtensionPtr extension_ptr =
make_so_pointer<IExtension>(l_flags.c_str());
plugin.AddExtension(extension_ptr);
}
if (n.hasParam("/object_detection/c")) {
std::string c_flags;
n.getParam("/object_detection/c", c_flags);
// GPU extensions are loaded from an .xml description and OpenCL kernel
// files
plugin.SetConfig(
{{PluginConfigParams::KEY_CONFIG_FILE, c_flags.c_str()}});
}
/** Per-layer metrics **/
if (n.hasParam("/object_detection/pc")) {
plugin.SetConfig(
{{PluginConfigParams::KEY_PERF_COUNT, PluginConfigParams::YES}});
}
// -----------------------------------------------------------------------------------------------------
// --------------- 2. Reading the IR generated by the Model Optimizer
// (.xml and .bin files) ------------
slog::info << "Loading network files" << slog::endl;
/** Reading network model **/
std::string model;
if (!n.getParam("/object_detection/model", model)) {
std::cout << "Model not found";
return 0;
}
netReader.ReadNetwork(model);
/** Setting batch size to 1 **/
slog::info << "Batch size is forced to 1." << slog::endl;
netReader.getNetwork().setBatchSize(1);
/** Extracting the model name and loading its weights **/
std::string binFileName = fileNameNoExt(model) + ".bin";
netReader.ReadWeights(binFileName);
/** Reading labels (if specified) **/
std::string labelFileName = fileNameNoExt(model) + ".labels";
std::vector<std::string> label_list;
std::ifstream inputFile(labelFileName);
std::copy(std::istream_iterator<std::string>(inputFile),
std::istream_iterator<std::string>(),
std::back_inserter(label_list));
labels = label_list;
// -----------------------------------------------------------------------------------------------------
/** YOLOV3-based network should have one input and three output **/
// --------------------------- 3. Configuring input and output
// -----------------------------------------
// --------------------------------- Preparing input blobs
// ---------------------------------------------
slog::info << "Checking that the inputs are as the demo expects"
<< slog::endl;
InputsDataMap inputInfo(netReader.getNetwork().getInputsInfo());
inputInf = inputInfo;
if (inputInfo.size() != 1) {
throw std::logic_error(
"This demo accepts networks that have only one input");
}
InputInfo::Ptr &input = inputInfo.begin()->second;
inputName = inputInfo.begin()->first;
input->setPrecision(Precision::U8);
if (n.hasParam("auto_resize")) {
input->getPreProcess().setResizeAlgorithm(
ResizeAlgorithm::RESIZE_BILINEAR);
input->getInputData()->setLayout(Layout::NHWC);
} else {
input->getInputData()->setLayout(Layout::NCHW);
}
// --------------------------------- Preparing output blobs
// -------------------------------------------
slog::info << "Checking that the outputs are as the demo expects"
<< slog::endl;
OutputsDataMap outputInfo(netReader.getNetwork().getOutputsInfo());
outputInf = outputInfo;
// if (outputInfo.size() != 3) {
// throw std::logic_error("This demo only accepts networks with three
// layers");
//}
for (auto &output : outputInfo) {
output.second->setPrecision(Precision::FP32);
output.second->setLayout(Layout::NCHW);
}
// -----------------------------------------------------------------------------------------------------
// --------------------------- 4. Loading model to the plugin
// ------------------------------------------
slog::info << "Loading model to the plugin" << slog::endl;
ExecutableNetwork network = plugin.LoadNetwork(netReader.getNetwork(), {});
// -----------------------------------------------------------------------------------------------------
// --------------------------- 5. Creating infer request
// -----------------------------------------------
async_infer_request_curr = network.CreateInferRequestPtr();
// -----------------------------------------------------------------------------------------------------
// --------------------------- 6. Doing inference
// ------------------------------------------------------
slog::info << "Start inference " << slog::endl;
ros::spin();
/** Showing performace results **/
if (n.hasParam("/object_detection/pc")) {
printPerformanceCounts(*async_infer_request_curr, std::cout);
}
} catch (const std::exception &error) {
std::cerr << "[ ERROR ] " << error.what() << std::endl;
return 1;
} catch (...) {
std::cerr << "[ ERROR ] Unknown/internal exception happened." << std::endl;
return 1;
}
slog::info << "Execution successful" << slog::endl;
return 0;
}

View File

@ -0,0 +1,220 @@
// Copyright (C) 2018 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
///////////////////////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <chrono>
#include <dirent.h>
#include <ext_list.hpp>
#include <fstream>
#include <functional>
#include <iostream>
#include <iterator>
#include <memory>
#include <random>
#include <string>
#include <vector>
// ROS packages
#include <cv_bridge/cv_bridge.h>
#include <openvino_object_detection/Object.h>
#include <openvino_object_detection/Objects.h>
#include <ros/ros.h>
#include <sensor_msgs/Image.h>
#include <inference_engine.hpp>
#include <samples/ocv_common.hpp>
#include <samples/slog.hpp>
using namespace InferenceEngine;
#define yolo_scale_13 13
#define yolo_scale_26 26
#define yolo_scale_52 52
void FrameToBlob(const cv::Mat &frame, InferRequest::Ptr &inferRequest,
const std::string &inputName, bool auto_resize) {
if (auto_resize) {
/* Just set input blob containing read image. Resize and layout conversion
* will be done automatically */
inferRequest->SetBlob(inputName, wrapMat2Blob(frame));
} else {
/* Resize and copy data from the image to the input blob */
Blob::Ptr frameBlob = inferRequest->GetBlob(inputName);
matU8ToBlob<uint8_t>(frame, frameBlob);
}
}
static int EntryIndex(int side, int lcoords, int lclasses, int location,
int entry) {
int n = location / (side * side);
int loc = location % (side * side);
return n * side * side * (lcoords + lclasses + 1) + entry * side * side + loc;
}
struct DetectionObject {
int xmin, ymin, xmax, ymax, class_id;
float confidence;
DetectionObject(double x, double y, double h, double w, int class_id,
float confidence, float h_scale, float w_scale) {
this->xmin = static_cast<int>((x - w / 2) * w_scale);
this->ymin = static_cast<int>((y - h / 2) * h_scale);
this->xmax = static_cast<int>(this->xmin + w * w_scale);
this->ymax = static_cast<int>(this->ymin + h * h_scale);
this->class_id = class_id;
this->confidence = confidence;
}
bool operator<(const DetectionObject &s2) const {
return this->confidence < s2.confidence;
}
};
double IntersectionOverUnion(const DetectionObject &box_1,
const DetectionObject &box_2) {
double width_of_overlap_area =
fmin(box_1.xmax, box_2.xmax) - fmax(box_1.xmin, box_2.xmin);
double height_of_overlap_area =
fmin(box_1.ymax, box_2.ymax) - fmax(box_1.ymin, box_2.ymin);
double area_of_overlap;
if (width_of_overlap_area < 0 || height_of_overlap_area < 0)
area_of_overlap = 0;
else
area_of_overlap = width_of_overlap_area * height_of_overlap_area;
double box_1_area = (box_1.ymax - box_1.ymin) * (box_1.xmax - box_1.xmin);
double box_2_area = (box_2.ymax - box_2.ymin) * (box_2.xmax - box_2.xmin);
double area_of_union = box_1_area + box_2_area - area_of_overlap;
return area_of_overlap / area_of_union;
}
void ParseYOLOV3Output(const CNNLayerPtr &layer, const Blob::Ptr &blob,
const unsigned long resized_im_h,
const unsigned long resized_im_w,
const unsigned long original_im_h,
const unsigned long original_im_w,
const double threshold,
std::vector<DetectionObject> &objects) {
// --------------------------- Validating output parameters
// -------------------------------------
if (layer->type != "RegionYolo")
throw std::runtime_error("Invalid output type: " + layer->type +
". RegionYolo expected");
const int out_blob_h = static_cast<int>(blob->getTensorDesc().getDims()[2]);
const int out_blob_w = static_cast<int>(blob->getTensorDesc().getDims()[3]);
if (out_blob_h != out_blob_w)
throw std::runtime_error("Invalid size of output " + layer->name +
" It should be in NCHW layout and H should be "
"equal to W. Current H = " +
std::to_string(out_blob_h) +
", current W = " + std::to_string(out_blob_h));
// --------------------------- Extracting layer parameters
// -------------------------------------
auto num = layer->GetParamAsInt("num");
try {
num = layer->GetParamAsInts("mask").size();
} catch (...) {
}
auto coords = layer->GetParamAsInt("coords");
auto classes = layer->GetParamAsInt("classes");
std::vector<float> anchors = {10.0, 13.0, 16.0, 30.0, 33.0, 23.0,
30.0, 61.0, 62.0, 45.0, 59.0, 119.0,
116.0, 90.0, 156.0, 198.0, 373.0, 326.0};
try {
anchors = layer->GetParamAsFloats("anchors");
} catch (...) {
}
auto side = out_blob_h;
int anchor_offset = 0;
// throw std::runtime_error("anchors.size() ==" +
// std::to_string(anchors.size()));
if (anchors.size() == 18) { // YoloV3
switch (side) {
case yolo_scale_13:
anchor_offset = 2 * 6;
break;
case yolo_scale_26:
anchor_offset = 2 * 3;
break;
case yolo_scale_52:
anchor_offset = 2 * 0;
break;
default:
throw std::runtime_error("Invalid output size");
}
} else if (anchors.size() == 12) { // tiny-YoloV3
switch (side) {
case yolo_scale_13:
anchor_offset = 2 * 3;
break;
case yolo_scale_26:
anchor_offset = 2 * 0;
break;
default:
throw std::runtime_error("Invalid output size");
}
} else { // ???
switch (side) {
case yolo_scale_13:
anchor_offset = 2 * 6;
break;
case yolo_scale_26:
anchor_offset = 2 * 3;
break;
case yolo_scale_52:
anchor_offset = 2 * 0;
break;
default:
throw std::runtime_error("Invalid output size");
}
}
auto side_square = side * side;
const float *output_blob =
blob->buffer().as<PrecisionTrait<Precision::FP32>::value_type *>();
// --------------------------- Parsing YOLO Region output
// -------------------------------------
for (int i = 0; i < side_square; ++i) {
int row = i / side;
int col = i % side;
for (int n = 0; n < num; ++n) {
int obj_index =
EntryIndex(side, coords, classes, n * side * side + i, coords);
int box_index = EntryIndex(side, coords, classes, n * side * side + i, 0);
float scale = output_blob[obj_index];
if (scale < threshold)
continue;
double x = (col + output_blob[box_index + 0 * side_square]) / side *
resized_im_w;
double y = (row + output_blob[box_index + 1 * side_square]) / side *
resized_im_h;
double height = std::exp(output_blob[box_index + 3 * side_square]) *
anchors[anchor_offset + 2 * n + 1];
double width = std::exp(output_blob[box_index + 2 * side_square]) *
anchors[anchor_offset + 2 * n];
for (int j = 0; j < classes; ++j) {
int class_index = EntryIndex(side, coords, classes, n * side_square + i,
coords + 1 + j);
float prob = scale * output_blob[class_index];
if (prob < threshold)
continue;
DetectionObject obj(x, y, height, width, j, prob,
static_cast<float>(original_im_h) /
static_cast<float>(resized_im_h),
static_cast<float>(original_im_w) /
static_cast<float>(resized_im_w));
objects.push_back(obj);
}
}
}
}

47
src/test.cpp Normal file
View File

@ -0,0 +1,47 @@
#include <cv_bridge/cv_bridge.h>
#include <opencv2/opencv.hpp>
#include <openvino_object_detection/Object.h>
#include <openvino_object_detection/Objects.h>
#include <ros/ros.h>
#include <sensor_msgs/Image.h>
using namespace cv;
int main(int argc, char **argv) {
ros::init(argc, argv, "object_detection_test");
// Handle creation
ros::NodeHandle n;
Mat frame;
VideoCapture cap("/home/yikes/vid/2.avi");
ros::ServiceClient client =
n.serviceClient<openvino_object_detection::Objects>("/tiny_yolov3");
openvino_object_detection::Objects t;
sensor_msgs::Image output_image_msg;
cv::namedWindow("view");
while (1) {
cap >> frame;
t.request.t = 0.5;
t.request.iou_t = 0.4;
t.request.img =
*cv_bridge::CvImage(std_msgs::Header(), "bgr8", frame).toImageMsg();
if (client.call(t)) {
std::cout << t.response.ms << "\n";
for (openvino_object_detection::Object obj : t.response.objects) {
std::ostringstream conf;
conf << ":" << std::fixed << std::setprecision(3) << obj.confidence;
cv::putText(frame, (std::string)obj.label + conf.str(),
cv::Point2f(obj.x - obj.w / 2, obj.y - obj.h / 2 - 5),
cv::FONT_HERSHEY_COMPLEX_SMALL, 1, cv::Scalar(0, 0, 255), 1,
cv::LINE_AA);
cv::rectangle(frame, cv::Point2f(obj.x - obj.w / 2, obj.y - obj.h / 2),
cv::Point2f(obj.x + obj.w / 2, obj.y + obj.h / 2),
cv::Scalar(0, 0, 255), 1, cv::LINE_AA);
}
cv::imshow("view", frame);
cv::waitKey(300);
}
ros::spinOnce();
}
}

7
srv/Objects.srv Normal file
View File

@ -0,0 +1,7 @@
sensor_msgs/Image img
float32 t
float32 iou_t
---
int16 len
Object[] objects
int32 ms