Skip to content

Commit

Permalink
[pj_det_yolox] add
Browse files Browse the repository at this point in the history
  • Loading branch information
iwatake2222 committed Mar 26, 2022
1 parent e087aa9 commit e67e66b
Show file tree
Hide file tree
Showing 11 changed files with 993 additions and 17 deletions.
32 changes: 16 additions & 16 deletions 00_doc/class_diagram.drawio
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<mxfile host="65bd71144e">
<diagram id="2nVCpC3mRS13LhFPs2z5" name="Page-1">
<mxGraphModel dx="1013" dy="1198" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="0" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
<mxGraphModel dx="1004" dy="1182" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="0" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
<root>
<mxCell id="0"/>
<mxCell id="1" parent="0"/>
Expand Down Expand Up @@ -40,49 +40,49 @@
<mxPoint as="offset"/>
</mxGeometry>
</mxCell>
<mxCell id="104" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#008a00;fontColor=#ffffff;strokeColor=#005700;fontSize=16;" vertex="1" parent="1">
<mxCell id="104" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#008a00;fontColor=#ffffff;strokeColor=#005700;fontSize=16;" parent="1" vertex="1">
<mxGeometry x="230" y="220" width="600" height="180" as="geometry"/>
</mxCell>
<mxCell id="105" value="TensorFlow Lite" style="rounded=0;whiteSpace=wrap;html=1;fontSize=16;" vertex="1" parent="1">
<mxCell id="105" value="TensorFlow Lite" style="rounded=0;whiteSpace=wrap;html=1;fontSize=16;" parent="1" vertex="1">
<mxGeometry x="406.7" y="250" width="130" height="40" as="geometry"/>
</mxCell>
<mxCell id="106" value="OpenCV" style="rounded=0;whiteSpace=wrap;html=1;fontSize=16;" vertex="1" parent="1">
<mxCell id="106" value="OpenCV" style="rounded=0;whiteSpace=wrap;html=1;fontSize=16;" parent="1" vertex="1">
<mxGeometry x="256.7" y="300" width="90" height="40" as="geometry"/>
</mxCell>
<mxCell id="107" value="OpenVINO" style="rounded=0;whiteSpace=wrap;html=1;fontSize=16;" vertex="1" parent="1">
<mxCell id="107" value="OpenVINO" style="rounded=0;whiteSpace=wrap;html=1;fontSize=16;" parent="1" vertex="1">
<mxGeometry x="366.7" y="300" width="100" height="40" as="geometry"/>
</mxCell>
<mxCell id="108" value="ncnn" style="rounded=0;whiteSpace=wrap;html=1;fontSize=16;" vertex="1" parent="1">
<mxCell id="108" value="ncnn" style="rounded=0;whiteSpace=wrap;html=1;fontSize=16;" parent="1" vertex="1">
<mxGeometry x="596.7" y="300" width="80" height="40" as="geometry"/>
</mxCell>
<mxCell id="109" value="MNN" style="rounded=0;whiteSpace=wrap;html=1;fontSize=16;" vertex="1" parent="1">
<mxCell id="109" value="MNN" style="rounded=0;whiteSpace=wrap;html=1;fontSize=16;" parent="1" vertex="1">
<mxGeometry x="696.7" y="300" width="80" height="40" as="geometry"/>
</mxCell>
<mxCell id="110" value="SNPE" style="rounded=0;whiteSpace=wrap;html=1;fontSize=16;" vertex="1" parent="1">
<mxCell id="110" value="SNPE" style="rounded=0;whiteSpace=wrap;html=1;fontSize=16;" parent="1" vertex="1">
<mxGeometry x="256.7" y="350" width="80" height="40" as="geometry"/>
</mxCell>
<mxCell id="111" value="Arm NN" style="rounded=0;whiteSpace=wrap;html=1;fontSize=16;" vertex="1" parent="1">
<mxCell id="111" value="Arm NN" style="rounded=0;whiteSpace=wrap;html=1;fontSize=16;" parent="1" vertex="1">
<mxGeometry x="356.7" y="350" width="80" height="40" as="geometry"/>
</mxCell>
<mxCell id="112" value="NNabla" style="rounded=0;whiteSpace=wrap;html=1;fontSize=16;" vertex="1" parent="1">
<mxCell id="112" value="NNabla" style="rounded=0;whiteSpace=wrap;html=1;fontSize=16;" parent="1" vertex="1">
<mxGeometry x="456.7" y="350" width="80" height="40" as="geometry"/>
</mxCell>
<mxCell id="113" value="TensorRT" style="rounded=0;whiteSpace=wrap;html=1;fontSize=16;" vertex="1" parent="1">
<mxCell id="113" value="TensorRT" style="rounded=0;whiteSpace=wrap;html=1;fontSize=16;" parent="1" vertex="1">
<mxGeometry x="486.7" y="300" width="90" height="40" as="geometry"/>
</mxCell>
<mxCell id="114" value="DL Frameworks" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontStyle=1;fontSize=18;" vertex="1" parent="1">
<mxCell id="114" value="DL Frameworks" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontStyle=1;fontSize=18;" parent="1" vertex="1">
<mxGeometry x="230" y="220" width="150" height="30" as="geometry"/>
</mxCell>
<mxCell id="115" value="LibTorch" style="rounded=0;whiteSpace=wrap;html=1;fontSize=16;" vertex="1" parent="1">
<mxCell id="115" value="LibTorch" style="rounded=0;whiteSpace=wrap;html=1;fontSize=16;" parent="1" vertex="1">
<mxGeometry x="556.7" y="250" width="80" height="40" as="geometry"/>
</mxCell>
<mxCell id="116" value="ONNX Runtime" style="rounded=0;whiteSpace=wrap;html=1;fontSize=16;" vertex="1" parent="1">
<mxCell id="116" value="ONNX Runtime" style="rounded=0;whiteSpace=wrap;html=1;fontSize=16;" parent="1" vertex="1">
<mxGeometry x="656.7" y="250" width="130" height="40" as="geometry"/>
</mxCell>
<mxCell id="117" value="TensorFlow" style="rounded=0;whiteSpace=wrap;html=1;fontSize=16;" vertex="1" parent="1">
<mxCell id="117" value="TensorFlow" style="rounded=0;whiteSpace=wrap;html=1;fontSize=16;" parent="1" vertex="1">
<mxGeometry x="256.7" y="250" width="130" height="40" as="geometry"/>
</mxCell>
<mxCell id="118" value="&lt;span style=&quot;font-weight: 700&quot;&gt;ClassificationEngine&lt;/span&gt;" style="html=1;fontSize=32;" vertex="1" parent="1">
<mxCell id="118" value="&lt;span style=&quot;&quot;&gt;ClassificationEngine&lt;/span&gt;" style="html=1;fontSize=32;fontStyle=0" parent="1" vertex="1">
<mxGeometry x="348.35" width="363.3" height="50" as="geometry"/>
</mxCell>
</root>
Expand Down
2 changes: 1 addition & 1 deletion InferenceHelper
Binary file added pj_det_yolox/00_doc/demo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions pj_det_yolox/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
cmake_minimum_required(VERSION 3.0)

# Create project
set(ProjectName "main")
project(${ProjectName})
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ${ProjectName})

# Select build system and set compile options
include(${CMAKE_CURRENT_LIST_DIR}/../common_helper/cmakes/build_setting.cmake)

# Create executable file
add_executable(${ProjectName} main.cpp)

# Link ImageProcessor module
add_subdirectory(./image_processor image_processor)
target_include_directories(${ProjectName} PUBLIC ./image_processor)
target_link_libraries(${ProjectName} ImageProcessor)

# For OpenCV
find_package(OpenCV REQUIRED)
target_include_directories(${ProjectName} PUBLIC ${OpenCV_INCLUDE_DIRS})
target_link_libraries(${ProjectName} ${OpenCV_LIBS})

# Copy resouce
file(COPY ${CMAKE_CURRENT_LIST_DIR}/../resource DESTINATION ${CMAKE_BINARY_DIR}/)
add_definitions(-DRESOURCE_DIR="${CMAKE_BINARY_DIR}/resource/")
39 changes: 39 additions & 0 deletions pj_det_yolox/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# YOLOX with TensorFlowLite/TensorRT/OpenCV/OpenVINO/ncnn/MNN/ArmNN/ONNXRuntime/TensorFlow in C++ on Windows/Linux/Linux(Arm)/Android

![00_doc/demo.jpg](00_doc/demo.jpg)]

## Target Environment, How to Build, How to Run
1. Please follow the instruction: https://github.com/iwatake2222/InferenceHelper_Sample
2. Build `pj_det_yolox` project (this directory)


## Tested environments
| Framework | Windows (x64) | Linux (x64) | Linux (aarch64) | Android (aarch64) |
|---------------------------|-----------------|-----------------|-----------------|-------------------|
| TensorFlow Lite | [x] | [x] | [x] | [x] |
| TensorFlow Lite + XNNPACK | [x] | [x] | [x] | [x] |
| TensorFlow Lite + EdgeTPU | [x] bad result | [ ] | [x] bad result | Unsupported |
| TensorFlow Lite + GPU | No library | No library | No library | [x] |
| TensorFlow Lite + NNAPI | No library | No library | No library | [x] |
| TensorRT | [x] | [ ] | [x] | No library |
| OpenCV(dnn) | [x] | [x] | [ ] | [x] |
| OpenVINO with OpenCV | [x] | [x] | Unsupported | Unsupported |
| ncnn | [x] | [x] | No library | [x] |
| MNN | [x] | [x] | [x] | [x] |
| ~~SNPE~~ | Unsupported | Unsupported | [ ] | [ ] |
| Arm NN | Unsupported | [ ] | [x] | No library |
| NNabla | [ ] no model | No library | No library | No library |
| ONNX Runtime | [x] | [x] | [x] | [ ] error |
| LibTorch | No model | No model | No model | No model |
| TensorFlow | [x] | [ ] | No library | No library |

## Note
- To run with OpenVINO, enable OpenCV and uncomment the following line
- `//#define MODEL_NAME "yolox_nano_480x640/model_float32.xml" /* for OpenVINO */`
- To run on Android, modify `ViewAndroid\app\src\main\cpp\CMakeLists.txt`
- `set(ImageProcessor_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../../../pj_det_yolox/image_processor")`

## Acknowledgements
- https://github.com/Megvii-BaseDetection/YOLOX
- https://github.com/PINTO0309/PINTO_model_zoo
- https://github.com/Tencent/ncnn
81 changes: 81 additions & 0 deletions pj_det_yolox/image_processor/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
cmake_minimum_required(VERSION 3.0)

set(LibraryName "ImageProcessor")

# Create library
add_library (${LibraryName} image_processor.cpp image_processor.h detection_engine.cpp detection_engine.h)

# For OpenCV
find_package(OpenCV REQUIRED)
target_include_directories(${LibraryName} PUBLIC ${OpenCV_INCLUDE_DIRS})
target_link_libraries(${LibraryName} ${OpenCV_LIBS})

# Link Common Helper module
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../../common_helper common_helper)
target_include_directories(${LibraryName} PUBLIC ${CMAKE_CURRENT_LIST_DIR}/../../common_helper)
target_link_libraries(${LibraryName} CommonHelper)

# For InferenceHelper
set(INFERENCE_HELPER_DIR ${CMAKE_CURRENT_LIST_DIR}/../../InferenceHelper/)
add_subdirectory(${INFERENCE_HELPER_DIR}/inference_helper inference_helper)
target_include_directories(${LibraryName} PUBLIC ${INFERENCE_HELPER_DIR}/inference_helper)
target_link_libraries(${LibraryName} InferenceHelper)

# Add definition to select framework automatically. You don't need this in the real product
if(INFERENCE_HELPER_ENABLE_OPENCV)
add_definitions(-DINFERENCE_HELPER_ENABLE_OPENCV)
endif()
if(INFERENCE_HELPER_ENABLE_TENSORRT)
add_definitions(-DINFERENCE_HELPER_ENABLE_TENSORRT)
endif()
if(INFERENCE_HELPER_ENABLE_TFLITE)
add_definitions(-DINFERENCE_HELPER_ENABLE_TFLITE)
endif()
if(INFERENCE_HELPER_ENABLE_TFLITE_DELEGATE_GPU)
add_definitions(-DINFERENCE_HELPER_ENABLE_TFLITE_DELEGATE_GPU)
endif()
if(INFERENCE_HELPER_ENABLE_TFLITE_DELEGATE_EDGETPU)
add_definitions(-DINFERENCE_HELPER_ENABLE_TFLITE_DELEGATE_EDGETPU)
endif()
if(INFERENCE_HELPER_ENABLE_TFLITE_DELEGATE_XNNPACK)
add_definitions(-DINFERENCE_HELPER_ENABLE_TFLITE_DELEGATE_XNNPACK)
endif()
if(INFERENCE_HELPER_ENABLE_TFLITE_DELEGATE_NNAPI)
add_definitions(-DINFERENCE_HELPER_ENABLE_TFLITE_DELEGATE_NNAPI)
endif()
if(INFERENCE_HELPER_ENABLE_NCNN)
add_definitions(-DINFERENCE_HELPER_ENABLE_NCNN)
endif()
if(INFERENCE_HELPER_ENABLE_MNN)
add_definitions(-DINFERENCE_HELPER_ENABLE_MNN)
endif()
if(INFERENCE_HELPER_ENABLE_SNPE)
add_definitions(-DINFERENCE_HELPER_ENABLE_SNPE)
endif()
if(INFERENCE_HELPER_ENABLE_ARMNN)
add_definitions(-DINFERENCE_HELPER_ENABLE_ARMNN)
endif()
if(INFERENCE_HELPER_ENABLE_NNABLA)
add_definitions(-DINFERENCE_HELPER_ENABLE_NNABLA)
endif()
if(INFERENCE_HELPER_ENABLE_NNABLA_CUDA)
add_definitions(-DINFERENCE_HELPER_ENABLE_NNABLA_CUDA)
endif()
if(INFERENCE_HELPER_ENABLE_ONNX_RUNTIME)
add_definitions(-DINFERENCE_HELPER_ENABLE_ONNX_RUNTIME)
endif()
if(INFERENCE_HELPER_ENABLE_ONNX_RUNTIME_CUDA)
add_definitions(-DINFERENCE_HELPER_ENABLE_ONNX_RUNTIME_CUDA)
endif()
if(INFERENCE_HELPER_ENABLE_LIBTORCH)
add_definitions(-DINFERENCE_HELPER_ENABLE_LIBTORCH)
endif()
if(INFERENCE_HELPER_ENABLE_LIBTORCH_CUDA)
add_definitions(-DINFERENCE_HELPER_ENABLE_LIBTORCH_CUDA)
endif()
if(INFERENCE_HELPER_ENABLE_TENSORFLOW)
add_definitions(-DINFERENCE_HELPER_ENABLE_TENSORFLOW)
endif()
if(INFERENCE_HELPER_ENABLE_TENSORFLOW_GPU)
add_definitions(-DINFERENCE_HELPER_ENABLE_TENSORFLOW_GPU)
endif()
Loading

0 comments on commit e67e66b

Please sign in to comment.