x-linux-ai: remove outdated recipes and unnecessary files
This commit removes all unnecessary files after the integration of the latest X-LINUX-AI v6.0.0 release from the meta-st-x-linux-ai layer for Yocto 5.0 (Scarthgap). https://onedigi.atlassian.net/browse/DEL-9419 Signed-off-by: Arturo Buzarra <arturo.buzarra@digi.com>
This commit is contained in:
parent
1c534c97b5
commit
78d02c2996
|
|
@ -1,47 +0,0 @@
|
|||
From a17c1c5d0b4957b5b3a65fc5d211f5ba6764d404 Mon Sep 17 00:00:00 2001
|
||||
From: Vincent ABRIOU <vincent.abriou@st.com>
|
||||
Date: Fri, 24 Mar 2023 11:09:00 +0100
|
||||
Subject: [PATCH 1/5] onnxruntime: test: remove AVX specific micro benchmark
|
||||
|
||||
Signed-off-by: Vincent ABRIOU <vincent.abriou@st.com>
|
||||
|
||||
%% original patch: 0001-onnxruntime-test-remove-AVX-specific-micro-benchmark.patch
|
||||
---
|
||||
.../test/onnx/microbenchmark/reduceminmax.cc | 24 -------------------
|
||||
1 file changed, 24 deletions(-)
|
||||
|
||||
diff --git a/onnxruntime/test/onnx/microbenchmark/reduceminmax.cc b/onnxruntime/test/onnx/microbenchmark/reduceminmax.cc
|
||||
index 06a7f50c9a..eeaa9e0067 100644
|
||||
--- a/onnxruntime/test/onnx/microbenchmark/reduceminmax.cc
|
||||
+++ b/onnxruntime/test/onnx/microbenchmark/reduceminmax.cc
|
||||
@@ -91,28 +91,4 @@ BENCHMARK(BM_FindMinMaxMlasSSE2)
|
||||
->Arg(98304)
|
||||
->Arg(160000);
|
||||
|
||||
-// MLAS avx implementation
|
||||
-static void BM_FindMinMaxMlasAvx(benchmark::State& state) {
|
||||
- const size_t batch_size = static_cast<size_t>(state.range(0));
|
||||
- float* data = GenerateArrayWithRandomValue<float>(batch_size, -1, 1);
|
||||
- float min = std::numeric_limits<float>::max();
|
||||
- float max = std::numeric_limits<float>::lowest();
|
||||
- for (auto _ : state) {
|
||||
- MlasReduceMinimumMaximumF32KernelAvx(data, &min, &max, batch_size);
|
||||
- }
|
||||
- aligned_free(data);
|
||||
-}
|
||||
-
|
||||
-BENCHMARK(BM_FindMinMaxMlasAvx)
|
||||
- ->UseRealTime()
|
||||
- ->UseRealTime()
|
||||
- ->Unit(benchmark::TimeUnit::kNanosecond)
|
||||
- ->Arg(100)
|
||||
- ->Arg(1000)
|
||||
- ->Arg(10000)
|
||||
- ->Arg(20000)
|
||||
- ->Arg(40000)
|
||||
- ->Arg(80000)
|
||||
- ->Arg(98304)
|
||||
- ->Arg(160000);
|
||||
|
||||
--
|
||||
2.25.1
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
From cb9bd5d833845a5e12c38b5b457fd232498efeb7 Mon Sep 17 00:00:00 2001
|
||||
From: Othmane AHL ZOUAOUI <othmane.ahlzouaoui@st.com>
|
||||
Date: Tue, 9 May 2023 13:33:14 +0200
|
||||
Subject: [PATCH 2/5] onnxruntime: add SONAME with MAJOR version
|
||||
|
||||
Signed-off-by: Othmane AHL ZOUAOUI <othmane.ahlzouaoui@st.com>
|
||||
|
||||
%% original patch: 0002-onnxruntime-add-SONAME-with-MAJOR-version.patch
|
||||
---
|
||||
cmake/CMakeLists.txt | 3 +++
|
||||
1 file changed, 3 insertions(+)
|
||||
|
||||
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
|
||||
index a5d28fb516..08a4c6af52 100644
|
||||
--- a/cmake/CMakeLists.txt
|
||||
+++ b/cmake/CMakeLists.txt
|
||||
@@ -1617,3 +1617,6 @@ if (onnxruntime_ENABLE_EXTERNAL_CUSTOM_OP_SCHEMAS)
|
||||
COMMENT "Installing protobuf"
|
||||
)
|
||||
endif()
|
||||
+
|
||||
+message("ONNXRUNTIME_VERSION_MAJOR=${ONNXRUNTIME_VERSION_MAJOR}")
|
||||
+set_target_properties(onnxruntime PROPERTIES SOVERSION "${ONNXRUNTIME_VERSION_MAJOR}")
|
||||
--
|
||||
2.25.1
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
From e13955dec97f7635cb055e86cb2db026f74e4823 Mon Sep 17 00:00:00 2001
|
||||
From: Othmane AHL ZOUAOUI <othmane.ahlzouaoui@st.com>
|
||||
Date: Tue, 9 May 2023 13:50:46 +0200
|
||||
Subject: [PATCH 3/5] onnxruntime: test: libcustom library remove relative
|
||||
|
||||
Signed-off-by: Othmane AHL ZOUAOUI <othmane.ahlzouaoui@st.com>
|
||||
|
||||
%% original patch: 0003-onnxruntime-test-libcustom-library-remove-relative.patch
|
||||
---
|
||||
onnxruntime/test/python/onnxruntime_test_python.py | 4 ++--
|
||||
onnxruntime/test/shared_lib/test_inference.cc | 4 ++--
|
||||
2 files changed, 4 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/onnxruntime/test/python/onnxruntime_test_python.py b/onnxruntime/test/python/onnxruntime_test_python.py
|
||||
index 89fd90ad3a..6bf0eb0399 100644
|
||||
--- a/onnxruntime/test/python/onnxruntime_test_python.py
|
||||
+++ b/onnxruntime/test/python/onnxruntime_test_python.py
|
||||
@@ -953,7 +953,7 @@ class TestInferenceSession(unittest.TestCase):
|
||||
raise FileNotFoundError("Unable to find '{0}'".format(shared_library))
|
||||
|
||||
else:
|
||||
- shared_library = "./libcustom_op_library.so"
|
||||
+ shared_library = "/usr/lib/libcustom_op_library.so"
|
||||
if not os.path.exists(shared_library):
|
||||
raise FileNotFoundError("Unable to find '{0}'".format(shared_library))
|
||||
|
||||
@@ -1312,7 +1312,7 @@ class TestInferenceSession(unittest.TestCase):
|
||||
return
|
||||
|
||||
else:
|
||||
- shared_library = "./libtest_execution_provider.so"
|
||||
+ shared_library = "/usr/lib/libtest_execution_provider.so"
|
||||
|
||||
if not os.path.exists(shared_library):
|
||||
raise FileNotFoundError("Unable to find '{0}'".format(shared_library))
|
||||
diff --git a/onnxruntime/test/shared_lib/test_inference.cc b/onnxruntime/test/shared_lib/test_inference.cc
|
||||
index 09219b40de..db4d73f4c0 100644
|
||||
--- a/onnxruntime/test/shared_lib/test_inference.cc
|
||||
+++ b/onnxruntime/test/shared_lib/test_inference.cc
|
||||
@@ -1302,7 +1302,7 @@ TEST(CApiTest, test_custom_op_library) {
|
||||
#elif defined(__APPLE__)
|
||||
lib_name = ORT_TSTR("libcustom_op_library.dylib");
|
||||
#else
|
||||
- lib_name = ORT_TSTR("./libcustom_op_library.so");
|
||||
+ lib_name = ORT_TSTR("libcustom_op_library.so");
|
||||
#endif
|
||||
|
||||
#ifdef USE_CUDA
|
||||
@@ -1329,7 +1329,7 @@ TEST(CApiTest, test_custom_op_library_registration_error) {
|
||||
#elif defined(__APPLE__)
|
||||
lib_name = ORT_TSTR("libcustom_op_invalid_library.dylib");
|
||||
#else
|
||||
- lib_name = ORT_TSTR("./libcustom_op_invalid_library.so");
|
||||
+ lib_name = ORT_TSTR("libcustom_op_invalid_library.so");
|
||||
#endif
|
||||
|
||||
Ort::SessionOptions session_options;
|
||||
--
|
||||
2.25.1
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
From 961ee9cf8510b4d9d87777105a338fa31a5d572a Mon Sep 17 00:00:00 2001
|
||||
From: Othmane AHL ZOUAOUI <othmane.ahlzouaoui@st.com>
|
||||
Date: Tue, 9 May 2023 14:03:04 +0200
|
||||
Subject: [PATCH 4/5] onnxruntime: fix imcompatibility with compiler GCC12.2.1
|
||||
bug
|
||||
|
||||
As stated in this issue below, the onnxruntime 14.4.0 release is
|
||||
not compatible with the version 12.2.1 of the GCC cross compiler.
|
||||
This patch is a workaround to fix this incompatibility bug.
|
||||
|
||||
Link to onnxruntime github issue:
|
||||
https://github.com/microsoft/onnxruntime/issues/14981
|
||||
|
||||
Signed-off-by: Othmane AHL ZOUAOUI <othmane.ahlzouaoui@st.com>
|
||||
|
||||
%% original patch: 0004-onnxruntime-fix-imcompatibility-with-compiler-GCC12..patch
|
||||
---
|
||||
onnxruntime/core/providers/cpu/tensor/scatter.cc | 4 ++++
|
||||
1 file changed, 4 insertions(+)
|
||||
|
||||
diff --git a/onnxruntime/core/providers/cpu/tensor/scatter.cc b/onnxruntime/core/providers/cpu/tensor/scatter.cc
|
||||
index 2d932dfe59..2e2f47d31f 100644
|
||||
--- a/onnxruntime/core/providers/cpu/tensor/scatter.cc
|
||||
+++ b/onnxruntime/core/providers/cpu/tensor/scatter.cc
|
||||
@@ -340,7 +340,11 @@ Status ScatterData(
|
||||
// and so on
|
||||
std::vector<int64_t> dim_block_size(num_dims);
|
||||
|
||||
+#if __GNUC__ >= 12
|
||||
+ dim_block_size[num_dims-1] = 1;
|
||||
+#else
|
||||
dim_block_size.back() = 1;
|
||||
+#endif
|
||||
if (num_dims > 1) {
|
||||
// We start at num_dims - 2 because we already pre-populated
|
||||
// the last element above
|
||||
--
|
||||
2.25.1
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
From 8195a2404f122d25814b851cd738cf0ff1e91d89 Mon Sep 17 00:00:00 2001
|
||||
From: Othmane AHL ZOUAOUI <othmane.ahlzouaoui@st.com>
|
||||
Date: Wed, 10 May 2023 10:39:00 +0200
|
||||
Subject: [PATCH 5/5] onnxruntime: avoid using unsupported Eigen headers
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
This patch removes the suspected Unsupported/Eigen/CXX11 headers and
|
||||
uses Onnx internal headers instead. It enables also the pragma for
|
||||
HAS_CLASS_MEMACCESS to treat the class-memaccess as warnings.
|
||||
This allows fixing the following build error: ‘void* memcpy(void*,
|
||||
const void*, size_t)’ copying an object of non-trivial type
|
||||
‘Eigen::internal::Packet4c’{aka ‘const signed char’}
|
||||
[-Werror=class-memaccess]
|
||||
|
||||
Signed-off-by: Othmane AHL ZOUAOUI <othmane.ahlzouaoui@st.com>
|
||||
|
||||
%% original patch: 0006-onnxruntime-avoid-using-unsupported-Eigen-headers.patch
|
||||
---
|
||||
onnxruntime/test/onnx/microbenchmark/eigen.cc | 15 ++++++++++++---
|
||||
1 file changed, 12 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/onnxruntime/test/onnx/microbenchmark/eigen.cc b/onnxruntime/test/onnx/microbenchmark/eigen.cc
|
||||
index b3b2c55600..00c317da50 100644
|
||||
--- a/onnxruntime/test/onnx/microbenchmark/eigen.cc
|
||||
+++ b/onnxruntime/test/onnx/microbenchmark/eigen.cc
|
||||
@@ -6,6 +6,13 @@
|
||||
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||
#pragma GCC diagnostic ignored "-Wunused-result"
|
||||
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
|
||||
+// cmake/external/eigen/unsupported/Eigen/CXX11/../../../Eigen/src/Core/arch/NEON/PacketMath.h:1633:9:
|
||||
+// error: ‘void* memcpy(void*, const void*, size_t)’ copying an object of non-trivial type ‘Eigen::internal::Packet4c’
|
||||
+// {aka ‘struct Eigen::internal::eigen_packet_wrapper<int, 2>’} from an array of ‘const int8_t’
|
||||
+// {aka ‘const signed char’} [-Werror=class-memaccess]
|
||||
+#ifdef HAS_CLASS_MEMACCESS
|
||||
+#pragma GCC diagnostic ignored "-Wclass-memaccess"
|
||||
+#endif
|
||||
#elif defined(_MSC_VER)
|
||||
// build\windows\debug\external\eigen3\unsupported\eigen\cxx11\src/Tensor/Tensor.h(76):
|
||||
// warning C4554: '&': check operator precedence for possible error; use parentheses to clarify precedence
|
||||
@@ -22,9 +29,11 @@
|
||||
#define EIGEN_USE_THREADS
|
||||
#endif
|
||||
|
||||
-#include <unsupported/Eigen/CXX11/ThreadPool>
|
||||
-#include <unsupported/Eigen/CXX11/Tensor>
|
||||
-#include <unsupported/Eigen/CXX11/src/Tensor/TensorDeviceThreadPool.h>
|
||||
+#include "core/platform/threadpool.h"
|
||||
+#include "core/common/eigen_common_wrapper.h"
|
||||
+#include "core/util/thread_utils.h"
|
||||
+#include <benchmark/benchmark.h>
|
||||
+
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#elif defined(_MSC_VER)
|
||||
--
|
||||
2.25.1
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
From a313277345bb498f9a788b905ed3f4e37ba31b57 Mon Sep 17 00:00:00 2001
|
||||
From: Othmane AHL ZOUAOUI <othmane.ahlzouaoui@st.com>
|
||||
Date: Tue, 30 May 2023 17:17:39 +0200
|
||||
Subject: [PATCH 6/6] onnxruntime: xnnpack: Fix -mcpu compiler build failure
|
||||
|
||||
The "-mcpu=" switch is introduced externaly into CMake by Yocto
|
||||
buildsystem toolchain. This switch is not compatible with XNNPACK
|
||||
build mechanism and causes the XNNPACK compilation break due to
|
||||
"unsupported instructions".
|
||||
This switch needs to be removed for XNNPACK In order to isolate
|
||||
the changes only for XNNPACK and its depencencies, a subfolder and
|
||||
a fix are introduced through this patch.
|
||||
|
||||
Signed-off-by: Othmane AHL ZOUAOUI <othmane.ahlzouaoui@st.com>
|
||||
---
|
||||
cmake/external/xnnpack.cmake | 12 ++++++++++++
|
||||
1 file changed, 12 insertions(+)
|
||||
|
||||
diff --git a/cmake/external/xnnpack.cmake b/cmake/external/xnnpack.cmake
|
||||
index 1fc2c6ccdc..62fad6ce38 100644
|
||||
--- a/cmake/external/xnnpack.cmake
|
||||
+++ b/cmake/external/xnnpack.cmake
|
||||
@@ -11,6 +11,18 @@ if(CMAKE_ANDROID_ARCH_ABI STREQUAL armeabi-v7a)
|
||||
set(XNNPACK_ENABLE_ARM_BF16 OFF)
|
||||
ENDIF()
|
||||
|
||||
+string(REGEX REPLACE "-mcpu=[-a-zA-Z0-9_.^$*+?]*" "" _tmp ${CMAKE_C_FLAGS})
|
||||
+set(CMAKE_C_FLAGS ${_tmp})
|
||||
+message("CMAKE_C_FLAGS: ${CMAKE_C_FLAGS}")
|
||||
+
|
||||
+string(REGEX REPLACE "-mcpu=[-a-zA-Z0-9_.^$*+?]*" "" _tmp ${CMAKE_ASM_FLAGS})
|
||||
+set(CMAKE_ASM_FLAGS ${_tmp})
|
||||
+message("CMAKE_ASM_FLAGS: ${CMAKE_ASM_FLAGS}")
|
||||
+
|
||||
+string(REGEX REPLACE "-mcpu=[-a-zA-Z0-9_.^$*+?]*" "" _tmp ${CMAKE_CXX_FLAGS})
|
||||
+set(CMAKE_CXX_FLAGS ${_tmp})
|
||||
+message("CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
|
||||
+
|
||||
# fp16 depends on psimd
|
||||
FetchContent_Declare(psimd URL ${DEP_URL_psimd} URL_HASH SHA1=${DEP_SHA1_psimd})
|
||||
onnxruntime_fetchcontent_makeavailable(psimd)
|
||||
--
|
||||
2.25.1
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
From ce4219ad77d422b9b5adc032ab911824ef212c41 Mon Sep 17 00:00:00 2001
|
||||
From: Othmane AHL ZOUAOUI <othmane.ahlzouaoui@st.com>
|
||||
Date: Wed, 20 Mar 2024 15:59:12 +0100
|
||||
Subject: [PATCH 1/1] onnxruntime: cmake: change visibility compilation options
|
||||
|
||||
Changing the compile options of the libonnxruntime shared lib
|
||||
to export all the symbols of the lib and make them visible during
|
||||
the runtime.
|
||||
|
||||
Signed-off-by: Othmane AHL ZOUAOUI <othmane.ahlzouaoui@st.com>
|
||||
---
|
||||
cmake/CMakeLists.txt | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
|
||||
index 08a4c6af52..1336ceb19b 100644
|
||||
--- a/cmake/CMakeLists.txt
|
||||
+++ b/cmake/CMakeLists.txt
|
||||
@@ -1620,3 +1620,5 @@ endif()
|
||||
|
||||
message("ONNXRUNTIME_VERSION_MAJOR=${ONNXRUNTIME_VERSION_MAJOR}")
|
||||
set_target_properties(onnxruntime PROPERTIES SOVERSION "${ONNXRUNTIME_VERSION_MAJOR}")
|
||||
+target_compile_options(onnxruntime PRIVATE -fvisibility=hidden)
|
||||
+target_compile_options(onnxruntime PRIVATE -fvisibility=default)
|
||||
--
|
||||
2.34.1
|
||||
|
|
@ -1,103 +0,0 @@
|
|||
# Copyright (C) 2023-2024, Digi International Inc.
|
||||
|
||||
FILESEXTRAPATHS:prepend := "${THISDIR}/files:"
|
||||
|
||||
PV = "1.14.0+git${SRCPV}"
|
||||
|
||||
SRCREV = "6ccaeddefa65ccac402a47fa4d9cad8229794bb2"
|
||||
SRC_URI = "gitsm://github.com/microsoft/onnxruntime.git;branch=rel-1.14.0;protocol=https"
|
||||
SRC_URI += " file://0001-onnxruntime-test-remove-AVX-specific-micro-benchmark.patch "
|
||||
SRC_URI += " file://0002-onnxruntime-add-SONAME-with-MAJOR-version.patch "
|
||||
SRC_URI += " file://0003-onnxruntime-test-libcustom-library-remove-relative.patch "
|
||||
SRC_URI += " file://0004-onnxruntime-fix-imcompatibility-with-compiler-GCC12.patch "
|
||||
SRC_URI += " file://0005-onnxruntime-avoid-using-unsupported-Eigen-headers.patch "
|
||||
SRC_URI += " file://0007-onnxruntime-cmake-change-visibility-compilation-opti.patch "
|
||||
SRC_URI:append:stm32mp2common = " file://0006-onnxruntime-xnnpack-Fix-mcpu-compiler-build-failure.patch "
|
||||
|
||||
PROTOC_VERSION = "3.20.2"
|
||||
SRC_URI += "https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip;name=protoc;subdir=protoc-${PROTOC_VERSION}/"
|
||||
SRC_URI[protoc.sha256sum] = "d97227fd8bc840dcb1cf7332c8339a2d8f0fc381a98b028006e5c9a911d07c2a"
|
||||
|
||||
S = "${WORKDIR}/git"
|
||||
|
||||
inherit python3-dir cmake
|
||||
|
||||
DEPENDS:append = "\
|
||||
${PYTHON_PN}-numpy \
|
||||
"
|
||||
|
||||
EXTRA_OECMAKE += " -DPython_NumPy_INCLUDE_DIR="${STAGING_LIBDIR}/${PYTHON_DIR}/site-packages/numpy/core/include" \
|
||||
-DBENCHMARK_ENABLE_GTEST_TESTS=OFF \
|
||||
-Donnxruntime_USE_XNNPACK=ON \
|
||||
-Donnxruntime_BUILD_UNIT_TESTS=ON \
|
||||
"
|
||||
|
||||
ONNX_TARGET_ARCH:aarch64="${@bb.utils.contains('TUNE_FEATURES', 'cortexa35', 'aarch64', '', d)}"
|
||||
|
||||
do_install() {
|
||||
|
||||
# Install onnxruntime dynamic library
|
||||
install -d ${D}${libdir}
|
||||
install -d ${D}${prefix}/local/bin/${PN}-${PVB}/tools
|
||||
install -d ${D}${prefix}/local/bin/${PN}-${PVB}/unit-tests
|
||||
|
||||
install -m 0644 ${B}/libonnxruntime.so ${D}${libdir}/libonnxruntime.so.${PVB}
|
||||
|
||||
# This shared lib is used by onnxruntime_shared_lib_test and onnxruntime_test_python.py
|
||||
install -m 644 ${B}/libcustom_op_library.so ${D}${libdir}
|
||||
|
||||
# And this one only by onnxruntime_test_python.py
|
||||
install -m 644 ${B}/libtest_execution_provider.so ${D}${libdir}
|
||||
install -m 644 ${B}/libonnxruntime_providers_shared.so ${D}${libdir}/libonnxruntime_providers_shared.so
|
||||
install -m 644 ${B}/libcustom_op_invalid_library.so ${D}${libdir}/libcustom_op_invalid_library.so
|
||||
install -m 644 ${B}/onnxruntime_pybind11_state.so ${D}${libdir}/onnxruntime_pybind11_state.so
|
||||
|
||||
# Install the symlinks.
|
||||
ln -sf libonnxruntime.so.${PVB} ${D}${libdir}/libonnxruntime.so.${MAJOR}
|
||||
ln -sf libonnxruntime.so.${PVB} ${D}${libdir}/libonnxruntime.so
|
||||
|
||||
# These are not included in the base installation, so we install them manually.
|
||||
install -m 755 ${B}/onnx_test_runner ${D}${prefix}/local/bin/${PN}-${PVB}/unit-tests
|
||||
install -m 755 ${B}/onnxruntime_perf_test ${D}${prefix}/local/bin/${PN}-${PVB}/tools
|
||||
install -m 755 ${B}/onnxruntime_test_all ${D}${prefix}/local/bin/${PN}-${PVB}/unit-tests
|
||||
install -m 755 ${B}/onnxruntime_shared_lib_test ${D}${prefix}/local/bin/${PN}-${PVB}/unit-tests
|
||||
install -m 755 ${B}/onnxruntime_api_tests_without_env ${D}${prefix}/local/bin/${PN}-${PVB}/unit-tests
|
||||
install -m 755 ${B}/onnxruntime_global_thread_pools_test ${D}${prefix}/local/bin/${PN}-${PVB}/unit-tests
|
||||
install -m 755 ${B}/onnxruntime_test_python.py ${D}${prefix}/local/bin/${PN}-${PVB}/unit-tests
|
||||
install -m 755 ${B}/helper.py ${D}${prefix}/local/bin/${PN}-${PVB}/unit-tests
|
||||
cp -r ${B}/testdata ${D}${prefix}/local/bin/${PN}-${PVB}/unit-tests
|
||||
|
||||
# We have to change some of the RPATH as well.
|
||||
chrpath -r '$ORIGIN' ${D}${prefix}/local/bin/${PN}-${PVB}/tools/onnxruntime_perf_test
|
||||
chrpath -r '$ORIGIN' ${D}${prefix}/local/bin/${PN}-${PVB}/unit-tests/onnxruntime_shared_lib_test
|
||||
chrpath -r '$ORIGIN' ${D}${prefix}/local/bin/${PN}-${PVB}/unit-tests/onnxruntime_api_tests_without_env
|
||||
chrpath -r '$ORIGIN' ${D}${prefix}/local/bin/${PN}-${PVB}/unit-tests/onnxruntime_global_thread_pools_test
|
||||
chrpath -r '$ORIGIN' ${D}${libdir}/libtest_execution_provider.so
|
||||
|
||||
# Install the Python package.
|
||||
mkdir -p ${D}${PYTHON_SITEPACKAGES_DIR}/onnxruntime
|
||||
cp -r ${B}/onnxruntime ${D}${PYTHON_SITEPACKAGES_DIR}
|
||||
|
||||
# Install header files
|
||||
install -d ${D}${includedir}/onnxruntime
|
||||
cd ${S}/onnxruntime
|
||||
cp --parents $(find . -name "*.h*" -not -path "*cmake_build/*") ${D}${includedir}/onnxruntime
|
||||
cp ${S}/include/onnxruntime/core/session/onnxruntime_cxx_api.h ${D}${includedir}/onnxruntime
|
||||
cp ${S}/include/onnxruntime/core/session/onnxruntime_c_api.h ${D}${includedir}/onnxruntime
|
||||
cp ${S}/include/onnxruntime/core/session/onnxruntime_cxx_inline.h ${D}${includedir}/onnxruntime
|
||||
}
|
||||
|
||||
# The package_qa() task does not like the fact that this library is present in both onnxruntime-tools
|
||||
# and python3-onnxruntime packages (the normal /usr/lib version and a copy placed inside the Python package).
|
||||
# So we simply mark the lib as a "private lib", to prevent the task from outputting an error.
|
||||
PRIVATE_LIBS = "libonnxruntime_providers_shared.so"
|
||||
|
||||
PACKAGES += "${PN}-unit-tests"
|
||||
PROVIDES += "${PN}-unit-tests"
|
||||
|
||||
FILES:${PN}-tools = "${prefix}/local/bin/${PN}-${PVB}/tools/onnxruntime_perf_test"
|
||||
FILES:${PN}-unit-tests = "${prefix}/local/bin/${PN}-${PVB}/unit-tests/* ${libdir}/libcustom_op_invalid_library.so ${libdir}/libtest_execution_provider.so ${libdir}/libcustom_op_library.so"
|
||||
|
||||
# onnxruntime_test_python.py unitary test requires python3-numpy and python3-onnxruntime packages
|
||||
RDEPENDS:${PN}-unit-tests += "${PYTHON_PN}-${PN}"
|
||||
RDEPENDS:${PYTHON_PN}-${PN} += "${PYTHON_PN}-numpy"
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
From c8af5997f3d9b851ff81ef1fb4045ec59f80d976 Mon Sep 17 00:00:00 2001
|
||||
From: Alexis BRISSON <alexis.brisson@st.com>
|
||||
Date: Wed, 10 May 2023 16:44:47 +0200
|
||||
Subject: [PATCH 1/1] TFLite add XNNPACK delegate u8 and i8 definition
|
||||
|
||||
Signed-off-by: Alexis BRISSON <alexis.brisson@st.com>
|
||||
---
|
||||
tensorflow/lite/CMakeLists.txt | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/tensorflow/lite/CMakeLists.txt b/tensorflow/lite/CMakeLists.txt
|
||||
index 073b29c4860..b3b89a4236c 100644
|
||||
--- a/tensorflow/lite/CMakeLists.txt
|
||||
+++ b/tensorflow/lite/CMakeLists.txt
|
||||
@@ -404,6 +404,8 @@ if(TFLITE_ENABLE_XNNPACK)
|
||||
TFLITE_DELEGATES_XNNPACK_SRCS
|
||||
FILTER ".*(_test|_tester)\\.(cc|h)"
|
||||
)
|
||||
+ add_definitions( -DXNNPACK_DELEGATE_ENABLE_QS8=1 )
|
||||
+ add_definitions( -DXNNPACK_DELEGATE_ENABLE_QU8=1 )
|
||||
list(APPEND TFLITE_TARGET_DEPENDENCIES
|
||||
XNNPACK
|
||||
)
|
||||
--
|
||||
2.25.1
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
From 78cbe3bb1970982adf32c9966b83789301d45cd8 Mon Sep 17 00:00:00 2001
|
||||
From: Maxence GUILHIN <maxence.guilhin@st.com>
|
||||
Date: Mon, 10 Jul 2023 15:47:59 +0200
|
||||
Subject: [PATCH 1/1] tensorflow-lite : fix aarch64 support for XNNPACK
|
||||
|
||||
The "-mcpu=" switch might be introduced externaly into CMake: either in <LANG>_FLAGS or
|
||||
as part of CC, CXX, ASM environmental variables (to be stored in CMAKE_<LANG>_COMPILER_ARG1).
|
||||
This switch is not compatible with XNNPACK build mechanism and causes the XNNPACK compilation
|
||||
break due to "unsupported instructions". This switch needs to be removed for XNNPACK
|
||||
In order to isolate the changes only for XNNPACK and its depencencies, a subfolder is
|
||||
introduced.
|
||||
|
||||
Signed-off-by: Maxence GUILHIN <maxence.guilhin@st.com>
|
||||
---
|
||||
tensorflow/lite/tools/cmake/modules/xnnpack.cmake | 14 ++++++++++++++
|
||||
1 file changed, 14 insertions(+)
|
||||
|
||||
diff --git a/tensorflow/lite/tools/cmake/modules/xnnpack.cmake b/tensorflow/lite/tools/cmake/modules/xnnpack.cmake
|
||||
index 24f0674cf92..028fc3a76e2 100644
|
||||
--- a/tensorflow/lite/tools/cmake/modules/xnnpack.cmake
|
||||
+++ b/tensorflow/lite/tools/cmake/modules/xnnpack.cmake
|
||||
@@ -38,6 +38,20 @@ endif()
|
||||
set(XNNPACK_BUILD_TESTS OFF CACHE BOOL "Disable XNNPACK test.")
|
||||
set(XNNPACK_BUILD_BENCHMARKS OFF CACHE BOOL "Disable XNNPACK benchmarks.")
|
||||
|
||||
+# The "-mcpu=" switch might be introduced externaly into CMake: either in <LANG>_FLAGS or
|
||||
+# as part of CC, CXX, ASM environmental variables (to be stored in CMAKE_<LANG>_COMPILER_ARG1).
|
||||
+# This switch is not compatible with XNNPACK build mechanism and causes the XNNPACK compilation
|
||||
+# break due to "unsupported instructions". This switch needs to be removed for XNNPACK
|
||||
+# In order to isolate the changes only for XNNPACK and its depencencies, a subfolder is
|
||||
+# introduced.
|
||||
+
|
||||
+foreach(FLAG IN ITEMS CMAKE_ASM_FLAGS CMAKE_ASM_COMPILER_ARG1 CMAKE_C_FLAGS CMAKE_C_COMPILER_ARG1 CMAKE_CXX_FLAGS CMAKE_CXX_COMPILER_ARG1)
|
||||
+ if(${FLAG})
|
||||
+ string(REGEX REPLACE "-mcpu=[-a-zA-Z0-9_.^$*+?]*" "" _tmp ${${FLAG}})
|
||||
+ set(${FLAG} ${_tmp})
|
||||
+ endif()
|
||||
+endforeach()
|
||||
+
|
||||
# The following line adds project of PTHREADPOOL, FP16 and XNNPACK which are
|
||||
# needed to compile XNNPACK delegate of TFLite.
|
||||
add_subdirectory(
|
||||
--
|
||||
2.25.1
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
From 0675ef8a401c5f77aeb674b006594190c7f58810 Mon Sep 17 00:00:00 2001
|
||||
From: Othmane AHL ZOUAOUI <othmane.ahlzouaoui@st.com>
|
||||
Date: Wed, 20 Mar 2024 15:05:40 +0100
|
||||
Subject: [PATCH 8/8] TFLite: cmake: change visibility compilation options
|
||||
|
||||
Changing the compile options of the libtensorflow-lite shared lib
|
||||
to export all the symbols of the lib and make them visible during
|
||||
the runtime.
|
||||
|
||||
Change-Id: I25a88a3ba29b00d1f40336e10acb898ab8b016a5
|
||||
Signed-off-by: Othmane AHL ZOUAOUI <othmane.ahlzouaoui@st.com>
|
||||
---
|
||||
tensorflow/lite/CMakeLists.txt | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/tensorflow/lite/CMakeLists.txt b/tensorflow/lite/CMakeLists.txt
|
||||
index 40812886306..f7bb65d894a 100644
|
||||
--- a/tensorflow/lite/CMakeLists.txt
|
||||
+++ b/tensorflow/lite/CMakeLists.txt
|
||||
@@ -517,6 +517,8 @@ set(_ALL_TFLITE_SRCS
|
||||
add_library(tensorflow-lite SHARED EXCLUDE_FROM_ALL
|
||||
${_ALL_TFLITE_SRCS}
|
||||
)
|
||||
+target_compile_options(tensorflow-lite PRIVATE -fvisibility=hidden)
|
||||
+target_compile_options(tensorflow-lite PRIVATE -fvisibility=default)
|
||||
set(_ALL_TFLITE_HDRS ${_ALL_TFLITE_SRCS})
|
||||
list(FILTER _ALL_TFLITE_HDRS INCLUDE REGEX ".*\\.h$")
|
||||
target_include_directories(tensorflow-lite
|
||||
--
|
||||
2.34.1
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
# Copyright (C) 2024, Digi International Inc.
|
||||
|
||||
FILESEXTRAPATHS:prepend := "${THISDIR}/files:"
|
||||
|
||||
SRC_URI += " file://0006-TFLite-cmake-add-XNNPACK-delegate-u8-and-i8-definition.patch "
|
||||
SRC_URI += " file://0008-TFLite-cmake-change-visibility-compilation-options.patch "
|
||||
SRC_URI:append:stm32mp2common = " file://0007-TFLite-fix-aarch64-support-for-XNNPACK.patch "
|
||||
|
||||
# Set building environment variables
|
||||
TENSORFLOW_TARGET:aarch64="linux"
|
||||
TENSORFLOW_TARGET_ARCH:aarch64="aarch64"
|
||||
|
||||
# Activate -O3 optimization and disable debug symbols
|
||||
OECMAKE_C_FLAGS_RELEASE = "-O3 -DNDEBUG"
|
||||
OECMAKE_CXX_FLAGS_RELEASE = "-O3 -DNDEBUG"
|
||||
# Build tensorflow-lite.so library, _pywrap_tensorflow_interpreter_wrapper.so library and the benchmark_model application
|
||||
OECMAKE_TARGET_COMPILE = "tensorflow-lite _pywrap_tensorflow_interpreter_wrapper benchmark_model"
|
||||
|
||||
EXTRA_OECMAKE += " -DTFLITE_ENABLE_XNNPACK=OFF "
|
||||
|
||||
do_compile() {
|
||||
# Standard CMAKE build.
|
||||
cmake_runcmake_build --target ${OECMAKE_TARGET_COMPILE}
|
||||
# Build the python wheel (procedure extract form the build_pip_package_with_cmake.sh)
|
||||
BUILD_DIR=${WORKDIR}/build
|
||||
TENSORFLOW_DIR=${S}
|
||||
TENSORFLOW_LITE_DIR="${TENSORFLOW_DIR}/tensorflow/lite"
|
||||
TENSORFLOW_VERSION=$(grep "_VERSION = " "${TENSORFLOW_DIR}/tensorflow/tools/pip_package/setup.py" | cut -d= -f2 | sed "s/[ '-]//g")
|
||||
mkdir -p "${BUILD_DIR}/tflite_runtime"
|
||||
cp -r "${TENSORFLOW_LITE_DIR}/tools/pip_package/debian" \
|
||||
"${TENSORFLOW_LITE_DIR}/tools/pip_package/MANIFEST.in" \
|
||||
"${BUILD_DIR}"
|
||||
cp -r "${TENSORFLOW_LITE_DIR}/python/interpreter_wrapper" "${BUILD_DIR}"
|
||||
cp "${TENSORFLOW_LITE_DIR}/tools/pip_package/setup_with_binary.py" "${BUILD_DIR}/setup.py"
|
||||
cp "${TENSORFLOW_LITE_DIR}/python/interpreter.py" \
|
||||
"${TENSORFLOW_LITE_DIR}/python/metrics/metrics_interface.py" \
|
||||
"${TENSORFLOW_LITE_DIR}/python/metrics/metrics_portable.py" \
|
||||
"${BUILD_DIR}/tflite_runtime"
|
||||
echo "__version__ = '${TENSORFLOW_VERSION}'" >> "${BUILD_DIR}/tflite_runtime/__init__.py"
|
||||
echo "__git_version__ = '$(git -C "${TENSORFLOW_DIR}" describe)'" >> "${BUILD_DIR}/tflite_runtime/__init__.py"
|
||||
|
||||
export PACKAGE_VERSION="${TENSORFLOW_VERSION}"
|
||||
export PROJECT_NAME="tflite_runtime"
|
||||
cp "${BUILD_DIR}/_pywrap_tensorflow_interpreter_wrapper.so" "tflite_runtime"
|
||||
|
||||
setuptools3_do_compile
|
||||
}
|
||||
|
||||
# Require the external NPU delegate.
|
||||
RDEPENDS:${PN}:append:stm32mp25common = " tflite-vx-delegate "
|
||||
|
|
@ -1,111 +0,0 @@
|
|||
commit 7ac938965051de91c493b75a8825b007e1f52599
|
||||
Author: Feiyue Chen <Feiyue.Chen@verisilicon.com>
|
||||
Date: Thu Jul 6 10:41:35 2023 +0000
|
||||
|
||||
Fixed bugs for kernel test building
|
||||
|
||||
diff --git a/tensorflow/lite/CMakeLists.txt b/tensorflow/lite/CMakeLists.txt
|
||||
index 073b29c4860..67486fa183b 100644
|
||||
--- a/tensorflow/lite/CMakeLists.txt
|
||||
+++ b/tensorflow/lite/CMakeLists.txt
|
||||
@@ -209,6 +209,8 @@ list(FILTER TFLITE_SRCS EXCLUDE REGEX ".*tflite_with_xnnpack\\.cc$")
|
||||
# Exclude Flex related files.
|
||||
list(FILTER TFLITE_SRCS EXCLUDE REGEX ".*with_selected_ops\\.cc$")
|
||||
|
||||
+list(FILTER TFLITE_SRCS EXCLUDE REGEX "tensorflow_profiler_logger\\.cc$")
|
||||
+
|
||||
if(_TFLITE_ENABLE_MMAP)
|
||||
list(FILTER TFLITE_SRCS EXCLUDE REGEX ".*mmap_allocation_disabled\\.cc$")
|
||||
else()
|
||||
diff --git a/tensorflow/lite/kernels/CMakeLists.txt b/tensorflow/lite/kernels/CMakeLists.txt
|
||||
index f5e22ee97da..d0da2680e7b 100644
|
||||
--- a/tensorflow/lite/kernels/CMakeLists.txt
|
||||
+++ b/tensorflow/lite/kernels/CMakeLists.txt
|
||||
@@ -63,16 +63,16 @@ build_flatbuffers(
|
||||
set(DELEGATE_PROVIDERS_SUPP
|
||||
${TFLITE_SOURCE_DIR}/nnapi/sl/SupportLibrary.cc
|
||||
${TFLITE_SOURCE_DIR}/tools/delegates/delegate_provider.cc
|
||||
- ${TFLITE_SOURCE_DIR}/tools/evaluation/utils.cc
|
||||
+ # ${TFLITE_SOURCE_DIR}/tools/evaluation/utils.cc
|
||||
)
|
||||
|
||||
set(DELEGATE_PROVIDERS
|
||||
${DELEGATE_PROVIDERS_SUPP}
|
||||
${TFLITE_SOURCE_DIR}/tools/delegates/default_execution_provider.cc
|
||||
# List of delegates referenced as options in the tensorflow/lite/CMakeLists.txt
|
||||
- ${TFLITE_SOURCE_DIR}/tools/delegates/gpu_delegate_provider.cc
|
||||
+ # ${TFLITE_SOURCE_DIR}/tools/delegates/gpu_delegate_provider.cc
|
||||
${TFLITE_SOURCE_DIR}/tools/delegates/nnapi_delegate_provider.cc
|
||||
- ${TFLITE_SOURCE_DIR}/tools/delegates/xnnpack_delegate_provider.cc
|
||||
+ # ${TFLITE_SOURCE_DIR}/tools/delegates/xnnpack_delegate_provider.cc
|
||||
)
|
||||
|
||||
if(TFLITE_ENABLE_EXTERNAL_DELEGATE)
|
||||
@@ -92,9 +92,9 @@ set(TEST_FRAMEWORK_SRC
|
||||
${TFLITE_SOURCE_DIR}/tools/tool_params.cc
|
||||
${TFLITE_SOURCE_DIR}/tools/versioning/op_version.cc
|
||||
${TFLITE_SOURCE_DIR}/tools/versioning/op_signature.cc
|
||||
- ${TF_SOURCE_DIR}/core/platform/default/env_time.cc
|
||||
- ${TF_SOURCE_DIR}/core/platform/default/logging.cc
|
||||
- ${TF_SOURCE_DIR}/core/platform/default/mutex.cc
|
||||
+ ${TF_SOURCE_DIR}/tsl/platform/default/env_time.cc
|
||||
+ ${TF_SOURCE_DIR}/tsl/platform/default/logging.cc
|
||||
+ ${TF_SOURCE_DIR}/tsl/platform/default/mutex.cc
|
||||
internal/test_util.cc
|
||||
acceleration_test_util.cc
|
||||
acceleration_test_util_internal.cc
|
||||
@@ -154,7 +154,8 @@ macro(add_kernel_test TEST_SRC TEST_LIB)
|
||||
set(DELEGATE_TEST "${TEST_NAME}_delegate")
|
||||
add_test(
|
||||
NAME ${DELEGATE_TEST}
|
||||
- COMMAND cmake -DTEST_EXECUTABLE=$<TARGET_FILE:${TEST_NAME}> -P run-tests.cmake
|
||||
+ # COMMAND cmake -DTEST_EXECUTABLE=$<TARGET_FILE:${TEST_NAME}> -P run-tests.cmake
|
||||
+ COMMAND cmake -DTEST_EXECUTABLE=$<TARGET_FILE:${TEST_NAME}> -P ${TFLITE_SOURCE_DIR}/tools/cmake/test_utils/run-tests.cmake
|
||||
)
|
||||
set_tests_properties(${DELEGATE_TEST} PROPERTIES LABELS "delegate")
|
||||
endif()
|
||||
diff --git a/tensorflow/lite/kernels/test_main.cc b/tensorflow/lite/kernels/test_main.cc
|
||||
index 1887533399b..6e3958b77dc 100644
|
||||
--- a/tensorflow/lite/kernels/test_main.cc
|
||||
+++ b/tensorflow/lite/kernels/test_main.cc
|
||||
@@ -16,7 +16,6 @@ limitations under the License.
|
||||
#include <vector>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
-#include "benchmark/benchmark.h" // from @com_google_benchmark
|
||||
#include "tensorflow/lite/kernels/test_delegate_providers.h"
|
||||
#include "tensorflow/lite/kernels/test_util.h"
|
||||
#include "tensorflow/lite/testing/util.h"
|
||||
@@ -51,7 +50,6 @@ int main(int argc, char** argv) {
|
||||
::tflite::LogToStderr();
|
||||
if (InitKernelTest(&argc, argv)) {
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
- benchmark::RunSpecifiedBenchmarks();
|
||||
return RUN_ALL_TESTS();
|
||||
} else {
|
||||
return EXIT_FAILURE;
|
||||
diff --git a/tensorflow/lite/kernels/unidirectional_sequence_lstm_test.cc b/tensorflow/lite/kernels/unidirectional_sequence_lstm_test.cc
|
||||
index cf3fd3a031a..e96f4e3f357 100644
|
||||
--- a/tensorflow/lite/kernels/unidirectional_sequence_lstm_test.cc
|
||||
+++ b/tensorflow/lite/kernels/unidirectional_sequence_lstm_test.cc
|
||||
@@ -18,7 +18,6 @@ limitations under the License.
|
||||
|
||||
#include <gmock/gmock.h>
|
||||
#include <gtest/gtest.h>
|
||||
-#include "benchmark/benchmark.h" // from @com_google_benchmark
|
||||
#include "flatbuffers/flatbuffers.h" // from @flatbuffers
|
||||
#include "tensorflow/lite/kernels/test_util.h"
|
||||
#include "tensorflow/lite/kernels/unidirectional_sequence_lstm_test_util.h"
|
||||
diff --git a/tensorflow/lite/tools/cmake/modules/flatbuffers.cmake b/tensorflow/lite/tools/cmake/modules/flatbuffers.cmake
|
||||
index 54b413f69ac..d7a2f8ce0f2 100644
|
||||
--- a/tensorflow/lite/tools/cmake/modules/flatbuffers.cmake
|
||||
+++ b/tensorflow/lite/tools/cmake/modules/flatbuffers.cmake
|
||||
@@ -23,7 +23,7 @@ OverridableFetchContent_Declare(
|
||||
flatbuffers
|
||||
GIT_REPOSITORY https://github.com/google/flatbuffers
|
||||
# Sync with tensorflow/third_party/flatbuffers/workspace.bzl
|
||||
- GIT_TAG v2.0.6
|
||||
+ GIT_TAG v2.0.8
|
||||
GIT_SHALLOW TRUE
|
||||
GIT_PROGRESS TRUE
|
||||
SOURCE_DIR "${CMAKE_BINARY_DIR}/flatbuffers"
|
||||
|
|
@ -1,71 +0,0 @@
|
|||
# Copyright 2020-2021 STMicroelectronics
|
||||
DESCRIPTION = "Verisilicon TFLite VX Delegate for STM32 Devices"
|
||||
LICENSE = "MIT"
|
||||
LIC_FILES_CHKSUM = "file://LICENSE;md5=7d6260e4f3f6f85de05af9c8f87e6fb5"
|
||||
|
||||
SRCBRANCH_vx = "main"
|
||||
SRCREV_vx = "a975b7ed7a5797812d3c5bdb7310ee92164d0a35"
|
||||
|
||||
SRCBRANCH_tf = "r2.11"
|
||||
SRCREV_tf = "5d37bd0350f0144632629c1aa2ebaef6ca76300b"
|
||||
|
||||
SRC_URI = "git://github.com/VeriSilicon/tflite-vx-delegate.git;branch=${SRCBRANCH_vx};name=vx;destsuffix=git_vx/;protocol=https \
|
||||
git://github.com/tensorflow/tensorflow;branch=${SRCBRANCH_tf};name=tf;destsuffix=git_tf/;protocol=https "
|
||||
SRC_URI += "file://0001-tflite-vx-delegate-fix-to-support-tflite-2-11.patch;patchdir=${WORKDIR}/git_tf"
|
||||
|
||||
PV = "2.11.0+git${SRCREV_vx}"
|
||||
S = "${WORKDIR}/git_vx"
|
||||
COMPATIBLE_MACHINE = "stm32mp25common"
|
||||
|
||||
inherit cmake
|
||||
DEPENDS += "tim-vx patchelf-native"
|
||||
|
||||
python () {
|
||||
#Get major of the PV variable
|
||||
version = d.getVar('PV')
|
||||
version = version.split("+")
|
||||
version_base = version[0]
|
||||
version = version_base.split(".")
|
||||
major = version[0]
|
||||
d.setVar('MAJOR', major)
|
||||
d.setVar('PVB', version_base)
|
||||
}
|
||||
|
||||
do_configure[network] = "1"
|
||||
|
||||
do_configure:prepend() {
|
||||
if [ -n "${http_proxy}" ]; then
|
||||
export HTTP_PROXY=${http_proxy}
|
||||
export http_proxy=${http_proxy}
|
||||
fi
|
||||
if [ -n "${https_proxy}" ]; then
|
||||
export HTTPS_PROXY=${https_proxy}
|
||||
export https_proxy=${https_proxy}
|
||||
fi
|
||||
unset FC
|
||||
}
|
||||
|
||||
EXTRA_OECMAKE += " -DFETCHCONTENT_SOURCE_DIR_TENSORFLOW=${WORKDIR}/git_tf \
|
||||
-DTIM_VX_INSTALL=${STAGING_DIR_TARGET}/usr \
|
||||
-DTFLITE_ENABLE_XNNPACK=OFF \
|
||||
-DTFLITE_ENABLE_EXTERNAL_DELEGATE=ON \
|
||||
-DFETCHCONTENT_FULLY_DISCONNECTED=OFF \
|
||||
"
|
||||
|
||||
do_install() {
|
||||
# Install libvx_delegate.so into libdir
|
||||
install -d ${D}${libdir}
|
||||
install -d ${D}${includedir}/VX
|
||||
install -m 0755 ${WORKDIR}/build/libvx_delegate.so ${D}${libdir}/libvx_delegate.so.${PVB}
|
||||
patchelf --set-soname libvx_delegate.so ${D}${libdir}/libvx_delegate.so.${PVB}
|
||||
ln -sf libvx_delegate.so.${PVB} ${D}${libdir}/libvx_delegate.so.${MAJOR}
|
||||
ln -sf libvx_delegate.so.${PVB} ${D}${libdir}/libvx_delegate.so
|
||||
|
||||
# Install cusom static lib
|
||||
install -m 0755 libvx_custom_op.a ${D}${libdir}/libvx_custom_op.a
|
||||
install -m 0644 ${S}/vsi_npu_custom_op.h ${D}${includedir}/VX/vsi_npu_custom_op.h
|
||||
}
|
||||
|
||||
FILES:${PN} += " ${libdir}/libvx_delegate.so.${MAJOR} \
|
||||
${libdir}/libvx_delegate.so.${PVB} \
|
||||
"
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
From 23cdc22779175fea6d73848a98e85702d99051c9 Mon Sep 17 00:00:00 2001
|
||||
From: Maxence GUILHIN <maxence.guilhin@st.com>
|
||||
Date: Mon, 4 Dec 2023 11:19:21 +0100
|
||||
Subject: [PATCH 1/1] tim-vx-tests : disable AVG_ANDROID tests which fails with
|
||||
tensor HDL OFF
|
||||
|
||||
Signed-off-by: Maxence GUILHIN <maxence.guilhin@st.com>
|
||||
---
|
||||
src/tim/transform/average_pool_layout_infer_test.cc | 2 +-
|
||||
src/tim/vx/ops/avg_pool_test.cc | 6 +++---
|
||||
2 files changed, 4 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/src/tim/transform/average_pool_layout_infer_test.cc b/src/tim/transform/average_pool_layout_infer_test.cc
|
||||
index 0ff8115..07048f3 100644
|
||||
--- a/src/tim/transform/average_pool_layout_infer_test.cc
|
||||
+++ b/src/tim/transform/average_pool_layout_infer_test.cc
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "tim/transform/layout_inference.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
-TEST(AVG_ANDROID, layout_infer_) {
|
||||
+TEST(AVG_ANDROID, DISABLED_layout_infer_) {
|
||||
auto ctx = tim::vx::Context::Create();
|
||||
auto graph = ctx->CreateGraph();
|
||||
|
||||
diff --git a/src/tim/vx/ops/avg_pool_test.cc b/src/tim/vx/ops/avg_pool_test.cc
|
||||
index 3a9aed8..3f3f17d 100644
|
||||
--- a/src/tim/vx/ops/avg_pool_test.cc
|
||||
+++ b/src/tim/vx/ops/avg_pool_test.cc
|
||||
@@ -463,7 +463,7 @@ TEST(AVG, shape_60_52_3_5_fp32_kernel_35_stride_5) {
|
||||
ArraysMatch(golden, output,1e-4f);
|
||||
}
|
||||
|
||||
-TEST(AVG_ANDROID, shape_60_52_3_5_fp32_kernel_35_stride_5) {
|
||||
+TEST(AVG_ANDROID, DISABLED_shape_60_52_3_5_fp32_kernel_35_stride_5) {
|
||||
auto ctx = tim::vx::Context::Create();
|
||||
auto graph = ctx->CreateGraph();
|
||||
|
||||
@@ -529,7 +529,7 @@ TEST(AVG_ANDROID, shape_60_52_3_5_fp32_kernel_35_stride_5) {
|
||||
ArraysMatch(golden, output, 1e-5f);
|
||||
}
|
||||
|
||||
-TEST(AVG_ANDROID, shape_60_52_3_5_fp32_kernel_50_stride_5) {
|
||||
+TEST(AVG_ANDROID, DISABLED_shape_60_52_3_5_fp32_kernel_50_stride_5) {
|
||||
auto ctx = tim::vx::Context::Create();
|
||||
auto graph = ctx->CreateGraph();
|
||||
|
||||
@@ -578,7 +578,7 @@ TEST(AVG_ANDROID, shape_60_52_3_5_fp32_kernel_50_stride_5) {
|
||||
ArraysMatch(golden, output, 1e-5f);
|
||||
}
|
||||
|
||||
-TEST(AVG_ANDROID, shape_60_52_3_5_uint8_kernel_35_stride_5) {
|
||||
+TEST(AVG_ANDROID, DISABLED_shape_60_52_3_5_uint8_kernel_35_stride_5) {
|
||||
auto ctx = tim::vx::Context::Create();
|
||||
auto graph = ctx->CreateGraph();
|
||||
|
||||
--
|
||||
2.25.1
|
||||
|
||||
|
|
@ -1,105 +0,0 @@
|
|||
DESCRIPTION = "TIM-VX is a software integration module provided by VeriSilicon to facilitate \
|
||||
deployment of Neural-Networks on OpenVX enabled ML accelerators. It serves as the backend \
|
||||
binding for runtime frameworks such as Android NN, Tensorflow-Lite, MLIR, TVM and more."
|
||||
SUMMARY = "Tensor Interface Module for OpenVX"
|
||||
HOMEPAGE = "https://github.com/VeriSilicon/TIM-VX"
|
||||
LICENSE = "MIT"
|
||||
|
||||
LIC_FILES_CHKSUM = "file://LICENSE;md5=d72cd187d764d96d91db827cb65b48a7"
|
||||
|
||||
SRCBRANCH_tim_vx = "main"
|
||||
SRCREV_tim_vx = "33f3a4f176ff9c407479eaf6be78c52bb3c7a939"
|
||||
SRC_URI ="git://github.com/VeriSilicon/TIM-VX.git;branch=${SRCBRANCH_tim_vx};name=tim_vx;destsuffix=tim_vx_git/;protocol=https"
|
||||
SRC_URI += " file://0001-tim-vx-tests-disable-AVG_ANDROID-tests.patch"
|
||||
|
||||
|
||||
SRCBRANCH_googletest = "main"
|
||||
SRCREV_googletest = "eab0e7e289db13eabfc246809b0284dac02a369d"
|
||||
SRC_URI +="git://github.com/google/googletest;branch=${SRCBRANCH_googletest};name=googletest;destsuffix=googletest/;protocol=https "
|
||||
|
||||
|
||||
PV = "1.1.57+git${SRCREV_tim_vx}"
|
||||
PV_googletest = "1.14.0"
|
||||
|
||||
S = "${WORKDIR}/tim_vx_git"
|
||||
|
||||
# Only compatible with stm32mp25
|
||||
COMPATIBLE_MACHINE = "stm32mp25common"
|
||||
|
||||
python () {
|
||||
#Get major of the PV variable
|
||||
version = d.getVar('PV')
|
||||
version = version.split("+")
|
||||
version_base = version[0]
|
||||
version = version_base.split(".")
|
||||
major = version[0]
|
||||
d.setVar('MAJOR', major)
|
||||
d.setVar('PVB', version_base)
|
||||
}
|
||||
|
||||
inherit cmake
|
||||
DEPENDS += " patchelf-native \
|
||||
gcnano-driver-stm32mp \
|
||||
gcnano-userland \
|
||||
gtest \
|
||||
googletest \
|
||||
"
|
||||
|
||||
EXTRA_OECMAKE = " \
|
||||
-DCONFIG=YOCTO \
|
||||
-DCMAKE_SYSROOT=${RECIPE_SYSROOT} \
|
||||
-DTIM_VX_ENABLE_TEST=ON \
|
||||
-DCMAKE_SKIP_RPATH=TRUE \
|
||||
-DFETCHCONTENT_FULLY_DISCONNECTED=OFF \
|
||||
-DTIM_VX_USE_EXTERNAL_OVXLIB=ON \
|
||||
-DTIM_VX_DBG_ENABLE_TENSOR_HNDL=OFF \
|
||||
-DOVXLIB_INC=${S}/src/tim/vx/internal/include/ \
|
||||
-DOVXLIB_LIB=${STAGING_LIBDIR}/libovxlib.so \
|
||||
-DFETCHCONTENT_SOURCE_DIR_GOOGLETEST=${WORKDIR}/googletest \
|
||||
"
|
||||
do_configure[network] = "1"
|
||||
|
||||
do_install() {
|
||||
# Install libtim-vx.so into libdir
|
||||
install -d ${D}${libdir}
|
||||
install -d ${D}/usr/local/bin/${PN}-${PVB}
|
||||
install -d ${D}/home/weston
|
||||
|
||||
install -m 0755 ${WORKDIR}/build/src/tim/libtim-vx.so ${D}${libdir}/libtim-vx.so.${PVB}
|
||||
patchelf --set-soname libtim-vx.so ${D}${libdir}/libtim-vx.so.${PVB}
|
||||
|
||||
ln -sf libtim-vx.so.${PVB} ${D}${libdir}/libtim-vx.so.${MAJOR}
|
||||
ln -sf libtim-vx.so.${PVB} ${D}${libdir}/libtim-vx.so
|
||||
|
||||
# Install other libraries for benchmark
|
||||
install -m 0755 ${WORKDIR}/build/lib/libgtest_main.so ${D}${libdir}/libgtest_main.so.${PV_googletest}
|
||||
install -m 0755 ${WORKDIR}/build/lib/libgtest.so ${D}${libdir}/libgtest.so.${PV_googletest}
|
||||
install -m 0755 ${WORKDIR}/build/lib/libgmock_main.so ${D}${libdir}/libgmock_main.so
|
||||
install -m 0755 ${WORKDIR}/build/lib/libgmock.so ${D}${libdir}/libgmock.so
|
||||
install -m 0755 ${WORKDIR}/build/src/tim/unit_test ${D}/usr/local/bin/${PN}-${PVB}/TIM-VX_test
|
||||
|
||||
# Include
|
||||
install -d ${D}${includedir}
|
||||
cp -r ${S}/include/tim ${D}${includedir}
|
||||
cp -r ${STAGING_INCDIR}/CL/cl_viv_vx_ext.h ${D}/usr/local/bin/${PN}-${PVB}/cl_viv_vx_ext.h
|
||||
cp -r ${STAGING_INCDIR}/CL/cl_viv_vx_ext.h ${D}/home/weston/cl_viv_vx_ext.h
|
||||
}
|
||||
|
||||
PACKAGES =+ "${PN}-tools"
|
||||
FILES_SOLIBSDEV = ""
|
||||
|
||||
FILES:${PN}-tools = " /usr/local/bin/${PN}-${PVB}/TIM-VX_test \
|
||||
/usr/local/bin/${PN}-${PVB}/cl_viv_vx_ext.h \
|
||||
/home/weston/cl_viv_vx_ext.h \
|
||||
${libdir}/libgtest_main.so.${PV_googletest} \
|
||||
${libdir}/libgtest.so.${PV_googletest} \
|
||||
${libdir}/libgmock_main.so \
|
||||
${libdir}/libgmock.so \
|
||||
"
|
||||
|
||||
FILES:${PN} += " ${libdir}/libtim-vx.so.${MAJOR} \
|
||||
${libdir}/libtim-vx.so.${PVB} \
|
||||
${libdir}/libtim-vx.so \
|
||||
"
|
||||
|
||||
INSANE_SKIP:${PN} += " dev-so "
|
||||
|
|
@ -1,63 +0,0 @@
|
|||
# Copyright (C) 2022, STMicroelectronics - All Rights Reserved
|
||||
SUMMARY = "TensorFlowLite C++ API Computer Vision image classification application example running on the EdgeTPU"
|
||||
LICENSE = "BSD-3-Clause & Apache-2.0"
|
||||
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/BSD-3-Clause;md5=550794465ba0ec5312d6919e203a55f9"
|
||||
LIC_FILES_CHKSUM += "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
|
||||
|
||||
inherit pkgconfig
|
||||
|
||||
DEPENDS += "tensorflow-lite libedgetpu gtk+3 opencv gstreamer1.0 gstreamer1.0-plugins-base gstreamer1.0-plugins-bad "
|
||||
|
||||
SRC_URI = " file://tflite;subdir=${BPN}-${PV} "
|
||||
|
||||
S = "${WORKDIR}/${BPN}-${PV}"
|
||||
|
||||
do_configure[noexec] = "1"
|
||||
|
||||
EXTRA_OEMAKE = 'SYSROOT="${RECIPE_SYSROOT}"'
|
||||
EXTRA_OEMAKE += 'EDGETPU=TRUE'
|
||||
|
||||
do_compile() {
|
||||
#Check the version of OpenCV and fill OPENCV_VERSION accordingly
|
||||
FILE=${RECIPE_SYSROOT}/${libdir}/pkgconfig/opencv4.pc
|
||||
if [ -f "$FILE" ]; then
|
||||
OPENCV_VERSION=opencv4
|
||||
else
|
||||
OPENCV_VERSION=opencv
|
||||
fi
|
||||
|
||||
oe_runmake OPENCV_PKGCONFIG=${OPENCV_VERSION} -C ${S}/tflite/
|
||||
}
|
||||
|
||||
do_install() {
|
||||
install -d ${D}${prefix}/local/demo/application
|
||||
install -d ${D}${prefix}/local/demo-ai/image-classification/coral/
|
||||
|
||||
# install applications into the demo launcher
|
||||
install -m 0755 ${S}/tflite/111-coral-image-classification-cpp.yaml ${D}${prefix}/local/demo/application
|
||||
|
||||
# install application binaries and launcher scripts
|
||||
install -m 0755 ${S}/tflite/tflite_image_classification ${D}${prefix}/local/demo-ai/image-classification/coral/coral_image_classification
|
||||
install -m 0755 ${S}/tflite/launch_coral_bin*.sh ${D}${prefix}/local/demo-ai/image-classification/coral
|
||||
}
|
||||
|
||||
FILES:${PN} += "${prefix}/local/"
|
||||
|
||||
INSANE_SKIP:${PN} = "ldflags"
|
||||
|
||||
RDEPENDS:${PN} += " \
|
||||
gstreamer1.0-plugins-bad-waylandsink \
|
||||
gstreamer1.0-plugins-bad-debugutilsbad \
|
||||
gstreamer1.0-plugins-base-app \
|
||||
gstreamer1.0-plugins-base-videorate \
|
||||
gstreamer1.0-plugins-good-video4linux2 \
|
||||
gstreamer1.0-plugins-base-videoconvertscale \
|
||||
gtk+3 \
|
||||
libedgetpu \
|
||||
libopencv-core \
|
||||
libopencv-imgproc \
|
||||
libopencv-imgcodecs \
|
||||
coral-models-mobilenetv1 \
|
||||
application-resources \
|
||||
bash \
|
||||
"
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
# Copyright (C) 2022, STMicroelectronics - All Rights Reserved
|
||||
SUMMARY = "TensorFlowLite Python Computer Vision image classification application examples running on the EdgeTPU"
|
||||
LICENSE = "BSD-3-Clause"
|
||||
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/BSD-3-Clause;md5=550794465ba0ec5312d6919e203a55f9"
|
||||
|
||||
SRC_URI = " file://tflite;subdir=${BPN}-${PV} "
|
||||
|
||||
S = "${WORKDIR}/${BPN}-${PV}"
|
||||
|
||||
do_configure[noexec] = "1"
|
||||
do_compile[noexec] = "1"
|
||||
|
||||
do_install() {
|
||||
install -d ${D}${prefix}/local/demo/application
|
||||
install -d ${D}${prefix}/local/demo-ai/image-classification/coral
|
||||
install -d ${D}${prefix}/local/demo-ai/image-classification/resources
|
||||
|
||||
# install applications into the demo launcher
|
||||
install -m 0755 ${S}/tflite/110-coral-image-classification-python.yaml ${D}${prefix}/local/demo/application
|
||||
|
||||
# install application binaries and launcher scripts
|
||||
install -m 0755 ${S}/tflite/tflite_image_classification.py ${D}${prefix}/local/demo-ai/image-classification/coral/coral_image_classification.py
|
||||
install -m 0755 ${S}/tflite/launch_coral_python*.sh ${D}${prefix}/local/demo-ai/image-classification/coral/
|
||||
}
|
||||
|
||||
FILES:${PN} += "${prefix}/local/"
|
||||
|
||||
RDEPENDS:${PN} += " \
|
||||
python3-core \
|
||||
python3-numpy \
|
||||
python3-opencv \
|
||||
python3-pillow \
|
||||
python3-pygobject \
|
||||
python3-tensorflow-lite \
|
||||
libedgetpu \
|
||||
coral-models-mobilenetv1 \
|
||||
application-resources \
|
||||
bash \
|
||||
"
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
Application:
|
||||
Name: Image Classification
|
||||
Description: Mobilenet v3
|
||||
Icon: ../demo-ai/resources/nbg_cpp.png
|
||||
Board:
|
||||
List: all
|
||||
Type: script
|
||||
Script:
|
||||
Exist:
|
||||
File: /usr/local/demo-ai/resources/check_camera_preview.sh
|
||||
Msg_false: Camera is not connected
|
||||
Start: ../demo-ai/image-classification/nbg/launch_bin_image_classification.sh
|
||||
Action:
|
||||
button_release_event: script_management
|
||||
button_press_event: highlight_eventBox
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
OPENCV_PKGCONFIG?="opencv4"
|
||||
SYSROOT?=""
|
||||
TARGET_BIN = nbg_image_classification
|
||||
|
||||
CXXFLAGS += -Wall $(shell pkg-config --cflags gtk+-3.0 $(OPENCV_PKGCONFIG) gstreamer-plugins-base-1.0 gstreamer-wayland-1.0)
|
||||
CXXFLAGS += -std=c++17
|
||||
|
||||
LDFLAGS = $(shell pkg-config --libs gtk+-3.0 gstreamer-plugins-base-1.0 gstreamer-wayland-1.0)
|
||||
LDFLAGS += -lpthread -ldl -lopencv_core -lopencv_imgproc -lopencv_imgcodecs
|
||||
LDFLAGS += -L$(SYSROOT)/usr/lib -ljpeg -lovxlib -lOpenVX -lOpenVXU
|
||||
LDFLAGS += -Wl,--no-as-needed
|
||||
|
||||
ifeq ($(NEW_GST_WAYLAND_API), 1)
|
||||
CXXFLAGS += -DNEW_GST_WAYLAND_API
|
||||
endif
|
||||
|
||||
SRCS = nbg_image_classification.cc vnn_utils.cc
|
||||
OBJS = $(SRCS:.cc=.o)
|
||||
|
||||
all: $(TARGET_BIN)
|
||||
|
||||
$(TARGET_BIN): $(OBJS)
|
||||
$(CXX) -o $@ $^ $(LDFLAGS)
|
||||
|
||||
$(OBJS): $(SRCS)
|
||||
$(CXX) $(CXXFLAGS) -c $^
|
||||
|
||||
clean:
|
||||
rm -rf $(OBJS) $(TARGET_BIN)
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
#!/bin/sh
|
||||
weston_user=$(ps aux | grep '/usr/bin/weston '|grep -v 'grep'|awk '{print $1}')
|
||||
|
||||
source /usr/local/demo-ai/resources/config_board.sh
|
||||
cmd="/usr/local/demo-ai/image-classification/nbg/nbg_image_classification -m /usr/local/demo-ai/image-classification/models/mobilenet/$IMAGE_CLASSIFICATION_MODEL.nb -l /usr/local/demo-ai/image-classification/models/mobilenet/$IMAGE_CLASSIFICATION_LABEL\_nbg.txt --framerate $DFPS --frame_width $DWIDTH --frame_height $DHEIGHT"
|
||||
|
||||
if [ "$weston_user" != "root" ]; then
|
||||
echo "user : "$weston_user
|
||||
script -qc "su -l $weston_user -c '$cmd'"
|
||||
else
|
||||
$cmd
|
||||
fi
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
#!/bin/sh
|
||||
weston_user=$(ps aux | grep '/usr/bin/weston '|grep -v 'grep'|awk '{print $1}')
|
||||
|
||||
source /usr/local/demo-ai/resources/config_board.sh
|
||||
cmd="/usr/local/demo-ai/image-classification/nbg/nbg_image_classification -m /usr/local/demo-ai/image-classification/models/mobilenet/$IMAGE_CLASSIFICATION_MODEL.nb -l /usr/local/demo-ai/image-classification/models/mobilenet/$IMAGE_CLASSIFICATION_LABEL\_nbg.txt -i /usr/local/demo-ai/image-classification/models/mobilenet/testdata/"
|
||||
|
||||
if [ "$weston_user" != "root" ]; then
|
||||
echo "user : "$weston_user
|
||||
script -qc "su -l $weston_user -c '$cmd'"
|
||||
else
|
||||
$cmd
|
||||
fi
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -1,124 +0,0 @@
|
|||
/*
|
||||
* vnn_utils.h
|
||||
*
|
||||
* This provides helper functions for nbg-benchmark tool and wrappers around OpenVX lib
|
||||
* function. The function are mainly used for converting data types and loading
|
||||
* network binary graph.
|
||||
*
|
||||
* Author: Othmane AHL ZOUAOUI <othmane.ahlzouaoui@st.com> for STMicroelectronics.
|
||||
*
|
||||
* Copyright (c) 2023 STMicroelectronics. All rights reserved.
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* 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.opensource.org/licenses/BSD-3-Clause
|
||||
*/
|
||||
|
||||
#ifndef _VNN_UTILS_H_
|
||||
#define _VNN_UTILS_H_
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
#include <assert.h>
|
||||
#include <VX/vx_khr_cnn.h>
|
||||
#include <VX/vx_khr_import_kernel.h>
|
||||
#include <VX/vx_lib_extras.h>
|
||||
|
||||
|
||||
#define MAX_NUM_DIMS 6
|
||||
#define MAX_IO_NAME_LENGTH 128
|
||||
#define VSI_NN_MAX_DEBUG_BUFFER_LEN 1024
|
||||
#define ZEROS(a) memset(a,0,sizeof(a))
|
||||
#define _CHECK_OBJ(ptr, label) \
|
||||
do \
|
||||
{ \
|
||||
if ((ptr) == NULL) \
|
||||
{ \
|
||||
printf("create fail: file=%s,line = %d\n", __FILE__,__LINE__); \
|
||||
goto label; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define _CHECK_STATUS(status, label) \
|
||||
do \
|
||||
{ \
|
||||
if (status != VX_SUCCESS) \
|
||||
{ \
|
||||
printf("process fail,status=%d, file=%s,line = %d\n",status,__FILE__, __LINE__); \
|
||||
goto label; \
|
||||
} \
|
||||
} while(0)
|
||||
typedef struct _inout_param
|
||||
{
|
||||
vx_uint32 dim_count;
|
||||
vx_uint32 dim_size[MAX_NUM_DIMS];
|
||||
vx_enum data_format;
|
||||
vx_enum data_type;
|
||||
vx_enum quan_format;
|
||||
vx_int8 fixed_pos;
|
||||
vx_float32 tf_scale;
|
||||
vx_int32 tf_zerop;
|
||||
vx_char name[MAX_IO_NAME_LENGTH];
|
||||
} inout_param;
|
||||
|
||||
typedef struct _inout_obj
|
||||
{
|
||||
vx_enum data_type;//image or tensor
|
||||
union
|
||||
{
|
||||
vx_reference ref;
|
||||
vx_image image;
|
||||
vx_tensor tensor;
|
||||
vx_array array;
|
||||
vx_scalar scalar;
|
||||
}u;
|
||||
|
||||
}inout_obj;
|
||||
typedef enum _file_type
|
||||
{
|
||||
FILE_TYPE_TEXT,
|
||||
FILE_TYPE_BIN,
|
||||
FILE_TYPE_NOT_SUPPORT
|
||||
}file_type;
|
||||
|
||||
vx_int8 vnn_Fp32toInt8(vx_float32 val, vx_int8 fixedPointPos);
|
||||
vx_float32 vnn_Int8toFp32(vx_int8 val, vx_int8 fixedPointPos);
|
||||
vx_uint8 vnn_Fp32toUint8(vx_float32 val, vx_int32 zeroPoint, vx_float32 scale);
|
||||
vx_float32 vnn_Uint8toFp32(vx_uint8 val, vx_int32 zeroPoint, vx_float32 scale);
|
||||
vx_float32 vnn_Int16toFp32(vx_int16 val, vx_int8 fixedPointPos);
|
||||
vx_int16 vnn_Fp32toInt16(vx_float32 val, vx_int8 fixedPointPos);
|
||||
vx_int16 vnn_Fp32toFp16(vx_float32 val);
|
||||
vx_float32 vnn_Fp16toFp32(const vx_uint16 in);
|
||||
vx_int8 vnn_Fp32toAsymInt8(vx_float32 val, vx_int32 zeroPoint, vx_float32 scale);
|
||||
vx_float32 vnn_AsymInt8toFp32(vx_int8 val, vx_int32 zeroPoint, vx_float32 scale);
|
||||
vx_int16 vnn_Fp32toAsymInt16(vx_float32 val, vx_int32 zeroPoint, vx_float32 scale);
|
||||
vx_float32 vnn_AsymInt16toFp32(vx_int16 val, vx_int32 zeroPoint, vx_float32 scale);
|
||||
|
||||
vx_uint32 vnn_GetTypeSize(vx_enum format);
|
||||
vx_uint32 vnn_GetTensorSize(vx_tensor tensor);
|
||||
vx_uint32 vnn_GetTensorDims(vx_tensor tensor);
|
||||
vx_uint32 vnn_GetTensorBufferSize(vx_tensor tensor);
|
||||
vx_status vnn_CopyTensorToData(vx_tensor tensor,void **buf);
|
||||
vx_status vnn_CopyTensorToFloat32Data(vx_tensor tensor,vx_float32 **buf);
|
||||
vx_status vnn_CopyDataToTensor(vx_tensor tensor,void *buf);
|
||||
vx_status vnn_CopyFloat32DataToTensor(vx_tensor tensor,vx_float32 *buf);
|
||||
vx_status vnn_LoadTensorFromFile(vx_tensor tensor,char *filename);
|
||||
vx_status vnn_SaveTensorToFileAsFloat32(vx_tensor tensor,char *filename);
|
||||
vx_status vnn_SaveTensorToFileAsBinary(vx_tensor tensor,char *filename);
|
||||
vx_status vnn_ShowTensorTop5(vx_tensor tensor);
|
||||
vx_status vnn_ShowTop5(inout_obj* obj);
|
||||
|
||||
vx_status vnn_LoadDataFromFile(inout_obj* obj,char *filename);
|
||||
vx_status vnn_LoadTensorRandom(vx_tensor tensor);
|
||||
vx_status vnn_SaveDataToFile(inout_obj* obj,char *filename);
|
||||
vx_status vnn_QueryInputsAndOutputsParam(vx_kernel kernel,inout_param *input,vx_int32 *in_cnt,inout_param *output,vx_int32 *out_cnt);
|
||||
vx_status vnn_CreateObject(vx_context context, inout_param *param, inout_obj *obj);
|
||||
vx_status vnn_ReleaseObject(inout_obj *obj);
|
||||
vx_bool get_top(float *pfProb, float *pfMaxProb, uint32_t *pMaxClass, uint32_t outputCount, uint32_t topNum);
|
||||
void vnn_Log(const char *fmt, ...);
|
||||
#endif
|
||||
|
|
@ -1,347 +0,0 @@
|
|||
/*
|
||||
* wrapper_tfl.hpp
|
||||
*
|
||||
* Author: Vincent Abriou <vincent.abriou@st.com> for STMicroelectronics.
|
||||
*
|
||||
* Copyright (c) 2020 STMicroelectronics. All rights reserved.
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* 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.opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
*
|
||||
*
|
||||
* Inspired by:
|
||||
* https://github.com/tensorflow/tensorflow/tree/master/tensorflow/lite/examples/label_image
|
||||
* Copyright 2017 The TensorFlow Authors. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*/
|
||||
|
||||
#ifndef WRAPPER_NBG_HPP_
|
||||
#define WRAPPER_NBG_HPP_
|
||||
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <queue>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
#include <assert.h>
|
||||
#include <getopt.h>
|
||||
#include <iostream>
|
||||
#include <time.h>
|
||||
#include <pthread.h>
|
||||
#include "vnn_utils.h"
|
||||
|
||||
#define GPU_CLK_FD "/sys/kernel/debug/gc/clk"
|
||||
#define NUM_OF_INPUT_MAX 32
|
||||
#define NUM_OF_OUTPUT_MAX 32
|
||||
#define BILLION 1000000000
|
||||
#define LOG(x) std::cerr
|
||||
|
||||
namespace wrapper_nbg
|
||||
{
|
||||
|
||||
double get_ms(struct timeval t) { return (t.tv_sec * 1000 + t.tv_usec / 1000); }
|
||||
|
||||
struct Config
|
||||
{
|
||||
bool verbose;
|
||||
std::string input_file;
|
||||
std::string model_name;
|
||||
std::string labels_file_name;
|
||||
int number_of_results = 5;
|
||||
};
|
||||
|
||||
struct Label_Results
|
||||
{
|
||||
float accuracy[10];
|
||||
int index[10];
|
||||
float inference_time;
|
||||
};
|
||||
|
||||
class NBG_Wrapper
|
||||
{
|
||||
private:
|
||||
vx_context m_context;
|
||||
vx_graph m_graph;
|
||||
vx_kernel m_kernel;
|
||||
vx_node m_node;
|
||||
vx_status m_status;
|
||||
vx_tensor m_input_tensor;
|
||||
vx_tensor m_output_tensor;
|
||||
vx_int32 m_input_count;
|
||||
vx_int32 m_output_count;
|
||||
vx_uint32 m_width;
|
||||
vx_uint32 m_height;
|
||||
bool m_verbose;
|
||||
bool m_inputFloating;
|
||||
float m_inferenceTime;
|
||||
int m_numberOfResults;
|
||||
std::string m_model;
|
||||
inout_obj m_inputs[NUM_OF_INPUT_MAX];
|
||||
inout_obj m_outputs[NUM_OF_OUTPUT_MAX];
|
||||
inout_param m_inputs_param[NUM_OF_INPUT_MAX];
|
||||
inout_param m_outputs_param[NUM_OF_OUTPUT_MAX];
|
||||
|
||||
public:
|
||||
NBG_Wrapper() {}
|
||||
|
||||
void Initialize(Config *conf)
|
||||
{
|
||||
m_context = {NULL};
|
||||
m_graph = {NULL};
|
||||
m_kernel = {NULL};
|
||||
m_node = {NULL};
|
||||
m_status = VX_FAILURE;
|
||||
m_input_tensor = NULL;
|
||||
m_output_tensor = NULL;
|
||||
m_input_count = 0;
|
||||
m_output_count = 0;
|
||||
m_width = 0;
|
||||
m_height = 0;
|
||||
m_inputFloating = false;
|
||||
m_inferenceTime = 0;
|
||||
m_model = conf->model_name;
|
||||
m_verbose = conf->verbose;
|
||||
m_numberOfResults = conf->number_of_results;
|
||||
|
||||
if (!m_model.c_str())
|
||||
{
|
||||
LOG(ERROR) << "no model file name\n";
|
||||
exit(-1);
|
||||
}
|
||||
LOG(INFO) << "Loaded model " << m_model << "\n";
|
||||
char *char_model = const_cast<char *>(m_model.c_str());
|
||||
|
||||
ZEROS(m_inputs_param);
|
||||
ZEROS(m_outputs_param);
|
||||
m_context = vxCreateContext();
|
||||
if (m_context == NULL)
|
||||
{
|
||||
LOG(FATAL) << "create fail: file=" << __FILE__ << ",line =" << __LINE__ << "\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
m_graph = vxCreateGraph(m_context);
|
||||
if (m_graph == NULL)
|
||||
{
|
||||
LOG(FATAL) << "create fail: file=" << __FILE__ << ",line =" << __LINE__ << "\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
m_kernel = vxImportKernelFromURL(m_context, VX_VIVANTE_IMPORT_KERNEL_FROM_FILE, char_model);
|
||||
m_status = vxGetStatus((vx_reference)m_kernel);
|
||||
if (m_status != VX_SUCCESS)
|
||||
{
|
||||
LOG(FATAL) << "process fail: status=" << m_status << ", file=" << __FILE__ << ",line =" << __LINE__ << "\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
m_node = vxCreateGenericNode(m_graph, m_kernel);
|
||||
m_status = vxGetStatus((vx_reference)m_node);
|
||||
if (m_status != VX_SUCCESS)
|
||||
{
|
||||
LOG(FATAL) << "process fail: status=" << m_status << ", file=" << __FILE__ << ",line =" << __LINE__ << "\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
m_status = vnn_QueryInputsAndOutputsParam(m_kernel, m_inputs_param, &m_input_count, m_outputs_param, &m_output_count);
|
||||
if (m_status != VX_SUCCESS)
|
||||
{
|
||||
LOG(FATAL) << "process fail: status=" << m_status << ", file=" << __FILE__ << ",line =" << __LINE__ << "\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
for (int j = 0; j < m_input_count; j++)
|
||||
{
|
||||
m_status |= vnn_CreateObject(m_context, &m_inputs_param[j], &m_inputs[j]);
|
||||
if (m_status != VX_SUCCESS)
|
||||
{
|
||||
LOG(FATAL) << "process fail: status=" << m_status << ", file=" << __FILE__ << ",line =" << __LINE__ << "\n";
|
||||
exit(1);
|
||||
}
|
||||
m_status |= vxSetParameterByIndex(m_node, j, (vx_reference)m_inputs[j].u.ref);
|
||||
if (m_status != VX_SUCCESS)
|
||||
{
|
||||
LOG(FATAL) << "process fail: status=" << m_status << ", file=" << __FILE__ << ",line =" << __LINE__ << "\n";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < m_output_count; j++)
|
||||
{
|
||||
m_status |= vnn_CreateObject(m_context, &m_outputs_param[j], &m_outputs[j]);
|
||||
if (m_status != VX_SUCCESS)
|
||||
{
|
||||
LOG(FATAL) << "process fail: status=" << m_status << ", file=" << __FILE__ << ",line =" << __LINE__ << "\n";
|
||||
exit(1);
|
||||
}
|
||||
m_status |= vxSetParameterByIndex(m_node, j + m_input_count, (vx_reference)m_outputs[j].u.ref);
|
||||
;
|
||||
if (m_status != VX_SUCCESS)
|
||||
{
|
||||
LOG(FATAL) << "process fail: status=" << m_status << ", file=" << __FILE__ << ",line =" << __LINE__ << "\n";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t tmsStart, tmsEnd, msVal, usVal;
|
||||
LOG(INFO) << "Info: Compiling and verifying graph...\n";
|
||||
tmsStart = get_perf_count();
|
||||
m_status = vxVerifyGraph(m_graph);
|
||||
if (m_status != VX_SUCCESS)
|
||||
{
|
||||
LOG(FATAL) << "process fail: status=" << m_status << ", file=" << __FILE__ << ",line =" << __LINE__ << "\n";
|
||||
exit(1);
|
||||
}
|
||||
tmsEnd = get_perf_count();
|
||||
msVal = (tmsEnd - tmsStart) / 1000000;
|
||||
usVal = (tmsEnd - tmsStart) / 1000;
|
||||
LOG(INFO) << "Info: Verifying graph took: " << msVal << " ms | " << usVal << " us\n";
|
||||
|
||||
inout_obj *obj = &m_inputs[0];
|
||||
m_input_tensor = obj->u.tensor;
|
||||
vx_int32 num_of_dims = vnn_GetTensorDims(m_input_tensor);
|
||||
vx_uint32 size[6];
|
||||
vxQueryTensor(m_input_tensor, VX_TENSOR_DIMS, size, sizeof(size));
|
||||
m_width = size[1];
|
||||
m_height = size[2];
|
||||
}
|
||||
|
||||
static uint64_t get_perf_count()
|
||||
{
|
||||
struct timespec ts;
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
return (uint64_t)((uint64_t)ts.tv_nsec + (uint64_t)ts.tv_sec * BILLION);
|
||||
}
|
||||
|
||||
void RunInference(uint8_t *img, Label_Results *results)
|
||||
{
|
||||
uint64_t tmsStart, tmsEnd;
|
||||
float msAvg, usAvg;
|
||||
float rUtil = 0;
|
||||
float rtime = 0;
|
||||
|
||||
vnn_CopyDataToTensor(m_input_tensor, img);
|
||||
if (m_status != VX_SUCCESS)
|
||||
{
|
||||
LOG(FATAL) << "process fail: status=" << m_status << ", file=" << __FILE__ << ",line =" << __LINE__ << "\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
tmsStart = get_perf_count();
|
||||
m_status = vxProcessGraph(m_graph);
|
||||
tmsEnd = get_perf_count();
|
||||
if (m_status != VX_SUCCESS)
|
||||
{
|
||||
LOG(FATAL) << "process fail: status=" << m_status << ", file=" << __FILE__ << ",line =" << __LINE__ << "\n";
|
||||
exit(1);
|
||||
}
|
||||
msAvg = (float)(tmsEnd - tmsStart) / 1000000;
|
||||
usAvg = (float)(tmsEnd - tmsStart) / 1000;
|
||||
m_inferenceTime = msAvg;
|
||||
|
||||
if (m_verbose)
|
||||
{
|
||||
LOG(INFO) << "Info: Initialized the graph\n";
|
||||
LOG(INFO) << "Info: Inf time Average: " << msAvg << " ms | " << usAvg << " us\n";
|
||||
}
|
||||
|
||||
vx_float32 *buf = NULL;
|
||||
vx_int32 num = vnn_GetTensorSize(m_outputs->u.tensor);
|
||||
if (m_verbose)
|
||||
LOG(INFO) << "Num of output: " << num << "\n";
|
||||
uint32_t MaxClass[5];
|
||||
vx_float32 fMaxProb[5];
|
||||
m_status |= vnn_CopyTensorToFloat32Data(m_outputs->u.tensor, &buf);
|
||||
if (m_status != VX_SUCCESS)
|
||||
{
|
||||
LOG(FATAL) << "process fail: status=" << m_status << ", file=" << __FILE__ << ",line =" << __LINE__ << "\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!get_top(buf, fMaxProb, MaxClass, num, m_numberOfResults))
|
||||
{
|
||||
LOG(FATAL) << "Fail to show result.\n";
|
||||
if (buf)
|
||||
{
|
||||
free(buf);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Get results */
|
||||
for (int i = 0; i < m_numberOfResults; i++)
|
||||
{
|
||||
if (m_verbose)
|
||||
{
|
||||
LOG(INFO) << "________________________________________\n________________________________________\n";
|
||||
LOG(INFO) << MaxClass[i] << " : " << fMaxProb[i] << "\n";
|
||||
LOG(INFO) << "________________________________________\n";
|
||||
}
|
||||
results->accuracy[i] = fMaxProb[i];
|
||||
results->index[i] = MaxClass[i];
|
||||
}
|
||||
results->inference_time = m_inferenceTime;
|
||||
|
||||
if (buf)
|
||||
{
|
||||
free(buf);
|
||||
}
|
||||
}
|
||||
|
||||
int GetInputWidth()
|
||||
{
|
||||
return int(m_width);
|
||||
}
|
||||
|
||||
int GetInputHeight()
|
||||
{
|
||||
return int(m_height);
|
||||
}
|
||||
|
||||
// Takes a file name, and loads a list of labels from it, one per line, and
|
||||
// returns a vector of the strings. It pads with empty strings so the length
|
||||
// of the result is a multiple of 16, because our model expects that.
|
||||
vx_status ReadLabelsFile(const std::string &file_name,
|
||||
std::vector<std::string> *result,
|
||||
size_t *found_label_count)
|
||||
{
|
||||
std::ifstream file(file_name);
|
||||
if (!file)
|
||||
{
|
||||
LOG(FATAL) << "Labels file " << file_name << " not found\n";
|
||||
return VX_FAILURE;
|
||||
}
|
||||
result->clear();
|
||||
std::string line;
|
||||
while (std::getline(file, line))
|
||||
{
|
||||
result->push_back(line);
|
||||
}
|
||||
*found_label_count = result->size();
|
||||
const int padding = 16;
|
||||
while (result->size() % padding)
|
||||
{
|
||||
result->emplace_back();
|
||||
}
|
||||
return VX_SUCCESS;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace wrapper_tfl
|
||||
|
||||
#endif // WRAPPER_TFL_HPP_
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
Application:
|
||||
Name: Image Classification
|
||||
Description: Mobilenet v3
|
||||
Icon: ../demo-ai/resources/onnx_python.png
|
||||
Board:
|
||||
List: all
|
||||
Type: script
|
||||
Script:
|
||||
Exist:
|
||||
File: /usr/local/demo-ai/resources/check_camera_preview.sh
|
||||
Msg_false: Camera is not connected
|
||||
Start: ../demo-ai/image-classification/onnx/launch_python_image_classification.sh
|
||||
Action:
|
||||
button_release_event: script_management
|
||||
button_press_event: highlight_eventBox
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
Application:
|
||||
Name: Image Classification
|
||||
Description: Mobilenet v1
|
||||
Icon: ../demo-ai/resources/onnx_python.png
|
||||
Board:
|
||||
List: all
|
||||
Type: script
|
||||
Script:
|
||||
Exist:
|
||||
File: /usr/local/demo-ai/resources/check_camera_preview.sh
|
||||
Msg_false: Camera is not connected
|
||||
Start: ../demo-ai/image-classification/onnx/launch_python_image_classification.sh
|
||||
Action:
|
||||
button_release_event: script_management
|
||||
button_press_event: highlight_eventBox
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
#!/bin/sh
|
||||
weston_user=$(ps aux | grep '/usr/bin/weston '|grep -v 'grep'|awk '{print $1}')
|
||||
|
||||
source /usr/local/demo-ai/resources/config_board.sh
|
||||
cmd="python3 /usr/local/demo-ai/image-classification/onnx/onnx_image_classification.py -m /usr/local/demo-ai/image-classification/models/mobilenet/$IMAGE_CLASSIFICATION_MODEL.onnx -l /usr/local/demo-ai/image-classification/models/mobilenet/$IMAGE_CLASSIFICATION_LABEL_onnx.txt --framerate $DFPS --frame_width $DWIDTH --frame_height $DHEIGHT"
|
||||
|
||||
if [ "$weston_user" != "root" ]; then
|
||||
echo "user : "$weston_user
|
||||
script -qc "su -l $weston_user -c '$cmd'"
|
||||
else
|
||||
$cmd
|
||||
fi
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
#!/bin/sh
|
||||
weston_user=$(ps aux | grep '/usr/bin/weston '|grep -v 'grep'|awk '{print $1}')
|
||||
|
||||
source /usr/local/demo-ai/resources/config_board.sh
|
||||
cmd="python3 /usr/local/demo-ai/image-classification/onnx/onnx_image_classification.py -m /usr/local/demo-ai/image-classification/models/mobilenet/$IMAGE_CLASSIFICATION_MODEL.onnx -l /usr/local/demo-ai/image-classification/models/mobilenet/$IMAGE_CLASSIFICATION_LABEL_onnx.txt -i /usr/local/demo-ai/image-classification/models/mobilenet/testdata/"
|
||||
if [ "$weston_user" != "root" ]; then
|
||||
echo "user : "$weston_user
|
||||
script -qc "su -l $weston_user -c '$cmd'"
|
||||
else
|
||||
$cmd
|
||||
fi
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,15 +0,0 @@
|
|||
Application:
|
||||
Name: Image Classification
|
||||
Description: Mobilenet v3
|
||||
Icon: ../demo-ai/resources/tfl_python.png
|
||||
Board:
|
||||
List: all
|
||||
Type: script
|
||||
Script:
|
||||
Exist:
|
||||
File: /usr/local/demo-ai/resources/check_camera_preview.sh
|
||||
Msg_false: Camera is not connected
|
||||
Start: ../demo-ai/image-classification/tflite/launch_python_image_classification.sh
|
||||
Action:
|
||||
button_release_event: script_management
|
||||
button_press_event: highlight_eventBox
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
Application:
|
||||
Name: Image Classification
|
||||
Description: Mobilenet v1
|
||||
Icon: ../demo-ai/resources/tfl_python.png
|
||||
Board:
|
||||
List: all
|
||||
Type: script
|
||||
Script:
|
||||
Exist:
|
||||
File: /usr/local/demo-ai/resources/check_camera_preview.sh
|
||||
Msg_false: Camera is not connected
|
||||
Start: ../demo-ai/image-classification/tflite/launch_python_image_classification.sh
|
||||
Action:
|
||||
button_release_event: script_management
|
||||
button_press_event: highlight_eventBox
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
Application:
|
||||
Name: Image Classification
|
||||
Description: Mobilenet v3
|
||||
Icon: ../demo-ai/resources/tfl_cpp.png
|
||||
Board:
|
||||
List: all
|
||||
Type: script
|
||||
Script:
|
||||
Exist:
|
||||
File: /usr/local/demo-ai/resources/check_camera_preview.sh
|
||||
Msg_false: Camera is not connected
|
||||
Start: ../demo-ai/image-classification/tflite/launch_bin_image_classification.sh
|
||||
Action:
|
||||
button_release_event: script_management
|
||||
button_press_event: highlight_eventBox
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
Application:
|
||||
Name: Image Classification
|
||||
Description: Mobilenet v1
|
||||
Icon: ../demo-ai/resources/tfl_cpp.png
|
||||
Board:
|
||||
List: all
|
||||
Type: script
|
||||
Script:
|
||||
Exist:
|
||||
File: /usr/local/demo-ai/resources/check_camera_preview.sh
|
||||
Msg_false: Camera is not connected
|
||||
Start: ../demo-ai/image-classification/tflite/launch_bin_image_classification.sh
|
||||
Action:
|
||||
button_release_event: script_management
|
||||
button_press_event: highlight_eventBox
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
Application:
|
||||
Name: Image Classification
|
||||
Description: Mobilenet v1
|
||||
Icon: ../demo-ai/resources/coral_python.png
|
||||
Board:
|
||||
List: all
|
||||
Type: script
|
||||
Script:
|
||||
Exist:
|
||||
File: /usr/local/demo-ai/resources/check_camera_preview.sh
|
||||
Msg_false: Camera is not connected
|
||||
Start: ../demo-ai/image-classification/coral/launch_coral_python_image_classification.sh
|
||||
Action:
|
||||
button_release_event: script_management
|
||||
button_press_event: highlight_eventBox
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
Application:
|
||||
Name: Image Classification
|
||||
Description: Mobilenet v1
|
||||
Icon: ../demo-ai/resources/coral_cpp.png
|
||||
Board:
|
||||
List: all
|
||||
Type: script
|
||||
Script:
|
||||
Exist:
|
||||
File: /usr/local/demo-ai/resources/check_camera_preview.sh
|
||||
Msg_false: Camera is not connected
|
||||
Start: ../demo-ai/image-classification/coral/launch_coral_bin_image_classification.sh
|
||||
Action:
|
||||
button_release_event: script_management
|
||||
button_press_event: highlight_eventBox
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
OPENCV_PKGCONFIG?="opencv4"
|
||||
SYSROOT?=""
|
||||
EDGETPU?=""
|
||||
ARCHITECTURE?=""
|
||||
TARGET_BIN = tflite_image_classification
|
||||
|
||||
CXXFLAGS += -Wall $(shell pkg-config --cflags gtk+-3.0 $(OPENCV_PKGCONFIG) gstreamer-plugins-base-1.0 gstreamer-wayland-1.0)
|
||||
CXXFLAGS += -std=c++17
|
||||
CXXFLAGS += -I$(SYSROOT)/usr/include/tensorflow/lite/flatbuffers/include
|
||||
CXXFLAGS += -I$(SYSROOT)/usr/include/tensorflow/lite/abseil-cpp
|
||||
|
||||
LDFLAGS = $(shell pkg-config --libs gtk+-3.0 gstreamer-plugins-base-1.0 gstreamer-wayland-1.0)
|
||||
LDFLAGS += -lpthread -ldl -lopencv_core -lopencv_imgproc -lopencv_imgcodecs -ltensorflow-lite
|
||||
ifneq (,$(findstring stm32mp2_npu,$(ARCHITECTURE)))
|
||||
CXXFLAGS += -DVSI_OP
|
||||
LDFLAGS += -lvx_custom_op
|
||||
endif
|
||||
|
||||
ifneq (,$(findstring TRUE,$(EDGETPU)))
|
||||
CXXFLAGS += -DEDGETPU
|
||||
LDFLAGS += -ledgetpu
|
||||
endif
|
||||
|
||||
SRCS = tflite_image_classification.cc
|
||||
OBJS = $(SRCS:.cc=.o)
|
||||
|
||||
all: $(TARGET_BIN)
|
||||
|
||||
$(TARGET_BIN): $(OBJS)
|
||||
$(CXX) -o $@ $^ $(LDFLAGS)
|
||||
|
||||
$(OBJS): $(SRCS)
|
||||
$(CXX) $(CXXFLAGS) -c $^
|
||||
|
||||
clean:
|
||||
rm -rf $(OBJS) $(TARGET_BIN)
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
#!/bin/sh
|
||||
weston_user=$(ps aux | grep '/usr/bin/weston '|grep -v 'grep'|awk '{print $1}')
|
||||
|
||||
source /usr/local/demo-ai/resources/config_board.sh
|
||||
cmd="/usr/local/demo-ai/image-classification/tflite/tflite_image_classification -m /usr/local/demo-ai/image-classification/models/mobilenet/$IMAGE_CLASSIFICATION_MODEL.tflite -l /usr/local/demo-ai/image-classification/models/mobilenet/$IMAGE_CLASSIFICATION_LABEL.txt --framerate $DFPS --frame_width $DWIDTH --frame_height $DHEIGHT $COMPUTE_ENGINE"
|
||||
|
||||
if [ "$weston_user" != "root" ]; then
|
||||
echo "user : "$weston_user
|
||||
script -qc "su -l $weston_user -c '$cmd'"
|
||||
else
|
||||
$cmd
|
||||
fi
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
#!/bin/sh
|
||||
weston_user=$(ps aux | grep '/usr/bin/weston '|grep -v 'grep'|awk '{print $1}')
|
||||
|
||||
source /usr/local/demo-ai/resources/config_board.sh
|
||||
cmd="/usr/local/demo-ai/image-classification/tflite/tflite_image_classification -m /usr/local/demo-ai/image-classification/models/mobilenet/$IMAGE_CLASSIFICATION_MODEL.tflite -l /usr/local/demo-ai/image-classification/models/mobilenet/$IMAGE_CLASSIFICATION_LABEL.txt -i /usr/local/demo-ai/image-classification/models/mobilenet/testdata/ $COMPUTE_ENGINE"
|
||||
|
||||
if [ "$weston_user" != "root" ]; then
|
||||
echo "user : "$weston_user
|
||||
script -qc "su -l $weston_user -c '$cmd'"
|
||||
else
|
||||
$cmd
|
||||
fi
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
#!/bin/sh
|
||||
weston_user=$(ps aux | grep '/usr/bin/weston '|grep -v 'grep'|awk '{print $1}')
|
||||
|
||||
source /usr/local/demo-ai/resources/config_board.sh
|
||||
cmd="/usr/local/demo-ai/image-classification/coral/coral_image_classification -m /usr/local/demo-ai/image-classification/models/mobilenet/mobilenet_v1_1.0_224_quant_edgetpu.tflite -l /usr/local/demo-ai/image-classification/models/mobilenet/labels.txt --framerate $DFPS --frame_width $DWIDTH --frame_height $DHEIGHT --edgetpu"
|
||||
|
||||
if [ "$weston_user" != "root" ]; then
|
||||
echo "user : "$weston_user
|
||||
script -qc "su -l $weston_user -c '$cmd'"
|
||||
else
|
||||
$cmd
|
||||
fi
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
#!/bin/sh
|
||||
weston_user=$(ps aux | grep '/usr/bin/weston '|grep -v 'grep'|awk '{print $1}')
|
||||
|
||||
cmd="/usr/local/demo-ai/image-classification/coral/coral_image_classification -m /usr/local/demo-ai/image-classification/models/mobilenet/mobilenet_v1_1.0_224_quant_edgetpu.tflite -l /usr/local/demo-ai/image-classification/models/mobilenet/labels.txt -i /usr/local/demo-ai/image-classification/models/mobilenet/testdata/ --edgetpu"
|
||||
if [ "$weston_user" != "root" ]; then
|
||||
echo "user : "$weston_user
|
||||
script -qc "su -l $weston_user -c '$cmd'"
|
||||
else
|
||||
$cmd
|
||||
fi
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
#!/bin/sh
|
||||
weston_user=$(ps aux | grep '/usr/bin/weston '|grep -v 'grep'|awk '{print $1}')
|
||||
|
||||
source /usr/local/demo-ai/resources/config_board.sh
|
||||
cmd="python3 /usr/local/demo-ai/image-classification/coral/coral_image_classification.py -m /usr/local/demo-ai/image-classification/models/mobilenet/mobilenet_v1_1.0_224_quant_edgetpu.tflite -l /usr/local/demo-ai/image-classification/models/mobilenet/labels.txt --framerate $DFPS --frame_width $DWIDTH --frame_height $DHEIGHT --edgetpu"
|
||||
|
||||
if [ "$weston_user" != "root" ]; then
|
||||
echo "user : "$weston_user
|
||||
script -qc "su -l $weston_user -c '$cmd'"
|
||||
else
|
||||
$cmd
|
||||
fi
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
#!/bin/sh
|
||||
weston_user=$(ps aux | grep '/usr/bin/weston '|grep -v 'grep'|awk '{print $1}')
|
||||
source /usr/local/demo-ai/resources/config_board.sh
|
||||
cmd="python3 /usr/local/demo-ai/image-classification/coral/coral_image_classification.py -m /usr/local/demo-ai/image-classification/models/mobilenet/mobilenet_v1_1.0_224_quant_edgetpu.tflite -l /usr/local/demo-ai/image-classification/models/mobilenet/labels.txt -i /usr/local/demo-ai/image-classification/models/mobilenet/testdata/ --edgetpu"
|
||||
|
||||
if [ "$weston_user" != "root" ]; then
|
||||
echo "user : "$weston_user
|
||||
script -qc "su -l $weston_user -c '$cmd'"
|
||||
else
|
||||
$cmd
|
||||
fi
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
#!/bin/sh
|
||||
weston_user=$(ps aux | grep '/usr/bin/weston '|grep -v 'grep'|awk '{print $1}')
|
||||
|
||||
source /usr/local/demo-ai/resources/config_board.sh
|
||||
cmd="python3 /usr/local/demo-ai/image-classification/tflite/tflite_image_classification.py -m /usr/local/demo-ai/image-classification/models/mobilenet/$IMAGE_CLASSIFICATION_MODEL.tflite -l /usr/local/demo-ai/image-classification/models/mobilenet/$IMAGE_CLASSIFICATION_LABEL.txt --framerate $DFPS --frame_width $DWIDTH --frame_height $DHEIGHT $COMPUTE_ENGINE"
|
||||
|
||||
if [ "$weston_user" != "root" ]; then
|
||||
echo "user : "$weston_user
|
||||
script -qc "su -l $weston_user -c '$cmd'"
|
||||
else
|
||||
$cmd
|
||||
fi
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
#!/bin/sh
|
||||
weston_user=$(ps aux | grep '/usr/bin/weston '|grep -v 'grep'|awk '{print $1}')
|
||||
|
||||
source /usr/local/demo-ai/resources/config_board.sh
|
||||
cmd="python3 /usr/local/demo-ai/image-classification/tflite/tflite_image_classification.py -m /usr/local/demo-ai/image-classification/models/mobilenet/$IMAGE_CLASSIFICATION_MODEL.tflite -l /usr/local/demo-ai/image-classification/models/mobilenet/$IMAGE_CLASSIFICATION_LABEL.txt -i /usr/local/demo-ai/image-classification/models/mobilenet/testdata/ $COMPUTE_ENGINE"
|
||||
|
||||
if [ "$weston_user" != "root" ]; then
|
||||
echo "user : "$weston_user
|
||||
script -qc "su -l $weston_user -c '$cmd'"
|
||||
else
|
||||
$cmd
|
||||
fi
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -1,385 +0,0 @@
|
|||
/*
|
||||
* wrapper_tfl.hpp
|
||||
*
|
||||
* Author: Vincent Abriou <vincent.abriou@st.com> for STMicroelectronics.
|
||||
*
|
||||
* Copyright (c) 2020 STMicroelectronics. All rights reserved.
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* 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.opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
*
|
||||
*
|
||||
* Inspired by:
|
||||
* https://github.com/tensorflow/tensorflow/tree/master/tensorflow/lite/examples/label_image
|
||||
* Copyright 2017 The TensorFlow Authors. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*/
|
||||
|
||||
#ifndef WRAPPER_TFL_HPP_
|
||||
#define WRAPPER_TFL_HPP_
|
||||
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <fstream>
|
||||
#include <queue>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <sys/time.h>
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
|
||||
#include "tensorflow/lite/kernels/register.h"
|
||||
#include "tensorflow/lite/model.h"
|
||||
#include "tensorflow/lite/optional_debug_tools.h"
|
||||
|
||||
#ifdef EDGETPU
|
||||
#include "tflite/public/edgetpu.h"
|
||||
#endif
|
||||
|
||||
#include "tensorflow/lite/delegates/external/external_delegate.h"
|
||||
#include "tensorflow/lite/interpreter.h"
|
||||
|
||||
#ifdef VSI_OP
|
||||
#include "VX/vsi_npu_custom_op.h"
|
||||
#endif
|
||||
|
||||
#define LOG(x) std::cerr
|
||||
|
||||
namespace wrapper_tfl {
|
||||
|
||||
double get_ms(struct timeval t) { return (t.tv_sec * 1000 + t.tv_usec / 1000); }
|
||||
|
||||
struct Config {
|
||||
bool verbose;
|
||||
float input_mean = 127.5f;
|
||||
float input_std = 127.5f;
|
||||
int number_of_threads = 2;
|
||||
int number_of_results = 5;
|
||||
std::string model_name;
|
||||
std::string labels_file_name;
|
||||
bool edgetpu;
|
||||
bool accel;
|
||||
std::string external_delegate_path;
|
||||
};
|
||||
|
||||
struct Label_Results {
|
||||
float accuracy[10];
|
||||
int index[10];
|
||||
float inference_time;
|
||||
};
|
||||
|
||||
class Tfl_Wrapper {
|
||||
private:
|
||||
// Taking a reference to the (const) model data avoids lifetime-related issues
|
||||
// and complexity with the TFL_Model's existence.
|
||||
#ifdef EDGETPU
|
||||
std::shared_ptr<edgetpu::EdgeTpuContext> m_edgetpu_ctx;
|
||||
#endif
|
||||
|
||||
std::unique_ptr<tflite::FlatBufferModel> m_model;
|
||||
std::unique_ptr<tflite::Interpreter> m_interpreter;
|
||||
bool m_verbose;
|
||||
bool m_inputFloating;
|
||||
bool m_allow_fp16;
|
||||
float m_inputMean;
|
||||
float m_inputStd;
|
||||
float m_inferenceTime;
|
||||
int m_numberOfThreads;
|
||||
int m_numberOfResults;
|
||||
bool m_edgetpu;
|
||||
bool m_accel;
|
||||
bool m_npu;
|
||||
const char * m_external_delegate_path;
|
||||
std::string m_vxdelegate;
|
||||
|
||||
public:
|
||||
Tfl_Wrapper() {}
|
||||
|
||||
void Initialize(Config* conf)
|
||||
{
|
||||
m_inputFloating = false;
|
||||
m_allow_fp16 = false;
|
||||
m_inferenceTime = 0;
|
||||
m_verbose = conf->verbose;
|
||||
m_inputMean = conf->input_mean;
|
||||
m_inputStd = conf->input_std;
|
||||
m_numberOfThreads = conf->number_of_threads;
|
||||
m_numberOfResults = conf->number_of_results;
|
||||
m_edgetpu = conf->edgetpu;
|
||||
|
||||
|
||||
if (m_edgetpu) {
|
||||
/* Check if the Edge TPU is connected */
|
||||
int status = system("lsusb -d 1a6e:");
|
||||
status &= system("lsusb -d 18d1:");
|
||||
if (status) {
|
||||
std::cout << "ERROR: Edge TPU not connected.\n";
|
||||
exit(-1);
|
||||
}
|
||||
/* Load EDGEPTU */
|
||||
#ifdef EDGETPU
|
||||
m_edgetpu_ctx = edgetpu::EdgeTpuManager::GetSingleton()->OpenDevice();
|
||||
#endif
|
||||
}
|
||||
m_inputFloating = false;
|
||||
m_allow_fp16 = false;
|
||||
m_inferenceTime = 0;
|
||||
m_verbose = conf->verbose;
|
||||
m_inputMean = conf->input_mean;
|
||||
m_inputStd = conf->input_std;
|
||||
m_numberOfThreads = conf->number_of_threads;
|
||||
m_numberOfResults = conf->number_of_results;
|
||||
m_accel = conf->accel;
|
||||
m_external_delegate_path = conf->external_delegate_path.c_str();
|
||||
m_vxdelegate = "libvx_delegate";
|
||||
m_npu = false;
|
||||
|
||||
/* Check which delegate is used */
|
||||
std::size_t found = conf->external_delegate_path.find(m_vxdelegate);
|
||||
if (found!=std::string::npos) {
|
||||
/* vx_delegate found */
|
||||
m_npu = true;
|
||||
}
|
||||
|
||||
if (!conf->model_name.c_str()) {
|
||||
LOG(ERROR) << "no model file name\n";
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
std::unique_ptr<tflite::FlatBufferModel> model;
|
||||
std::unique_ptr<tflite::Interpreter> interpreter;
|
||||
model = tflite::FlatBufferModel::BuildFromFile(conf->model_name.c_str());
|
||||
if (!model) {
|
||||
LOG(FATAL) << "\nFailed to mmap model " << conf->model_name << "\n";
|
||||
exit(-1);
|
||||
}
|
||||
LOG(INFO) << "Loaded model " << conf->model_name << "\n";
|
||||
model->error_reporter();
|
||||
|
||||
tflite::ops::builtin::BuiltinOpResolver resolver;
|
||||
|
||||
if(m_edgetpu){
|
||||
#ifdef EDGETPU
|
||||
resolver.AddCustom(edgetpu::kCustomOp, edgetpu::RegisterCustomOp());
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef VSI_OP
|
||||
if(m_accel && m_npu) {
|
||||
resolver.AddCustom(kNbgCustomOp, tflite::ops::custom::Register_VSI_NPU_PRECOMPILED());
|
||||
}
|
||||
#endif
|
||||
|
||||
tflite::InterpreterBuilder(*model, resolver)(&interpreter);
|
||||
if (!interpreter) {
|
||||
LOG(FATAL) << "Failed to construct interpreter\n";
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
#ifdef VSI_OP
|
||||
if(m_accel) {
|
||||
const char * delegate_path = m_external_delegate_path;
|
||||
auto ext_delegate_option = TfLiteExternalDelegateOptionsDefault(delegate_path);
|
||||
ext_delegate_option.insert(&ext_delegate_option, "cache_file_path", "/usr/local/demo-ai/image-classification/models/mobilenet/mobilenet_v3_large_100_224_quant.nb");
|
||||
ext_delegate_option.insert(&ext_delegate_option, "allowed_cache_mode", "true");
|
||||
auto ext_delegate_ptr = TfLiteExternalDelegateCreate(&ext_delegate_option);
|
||||
interpreter->ModifyGraphWithDelegate(ext_delegate_ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
int input = interpreter->inputs()[0];
|
||||
if (interpreter->tensor(input)->type == kTfLiteFloat32) {
|
||||
m_inputFloating = true;
|
||||
LOG(INFO) << "Floating point Tensorflow Lite Model\n";
|
||||
}
|
||||
|
||||
if(m_edgetpu){
|
||||
#ifdef EDGETPU
|
||||
interpreter->SetExternalContext(kTfLiteEdgeTpuContext, m_edgetpu_ctx.get());
|
||||
#endif
|
||||
} else {
|
||||
interpreter->SetAllowFp16PrecisionForFp32(m_allow_fp16);
|
||||
}
|
||||
|
||||
if (m_numberOfThreads != -1) {
|
||||
interpreter->SetNumThreads(m_numberOfThreads);
|
||||
}
|
||||
|
||||
m_interpreter = std::move(interpreter);
|
||||
m_model = std::move(model);
|
||||
}
|
||||
|
||||
void DisplaySettings()
|
||||
{
|
||||
LOG(INFO) << "input_floating " << m_inputFloating << "\n";
|
||||
LOG(INFO) << "allow_fp16 " << m_allow_fp16 << "\n";
|
||||
LOG(INFO) << "input_mean " << m_inputMean << "\n";
|
||||
LOG(INFO) << "input_std " << m_inputStd << "\n";
|
||||
LOG(INFO) << "number_of_threads " << m_numberOfThreads << "\n";
|
||||
LOG(INFO) << "number_of_results " << m_numberOfResults << "\n";
|
||||
LOG(INFO) << "edgetpu " << m_edgetpu << "\n";
|
||||
}
|
||||
|
||||
void DisplayModelInformation()
|
||||
{
|
||||
LOG(INFO) << "tensors size: " << m_interpreter->tensors_size() << "\n";
|
||||
LOG(INFO) << "nodes size: " << m_interpreter->nodes_size() << "\n";
|
||||
LOG(INFO) << "inputs: " << m_interpreter->inputs().size() << "\n";
|
||||
LOG(INFO) << "input(0) name: " << m_interpreter->GetInputName(0) << "\n";
|
||||
|
||||
int t_size = m_interpreter->tensors_size();
|
||||
for (int i = 0; i < t_size; i++) {
|
||||
if (m_interpreter->tensor(i)->name)
|
||||
LOG(INFO) << i << ": " << m_interpreter->tensor(i)->name << ", "
|
||||
<< m_interpreter->tensor(i)->bytes << ", "
|
||||
<< m_interpreter->tensor(i)->type << ", "
|
||||
<< m_interpreter->tensor(i)->params.scale << ", "
|
||||
<< m_interpreter->tensor(i)->params.zero_point << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
bool IsModelQuantized()
|
||||
{
|
||||
return !m_inputFloating;
|
||||
}
|
||||
|
||||
int GetInputWidth()
|
||||
{
|
||||
int input = m_interpreter->inputs()[0];
|
||||
TfLiteIntArray* input_dims = m_interpreter->tensor(input)->dims;
|
||||
return input_dims->data[2];
|
||||
}
|
||||
|
||||
int GetInputHeight()
|
||||
{
|
||||
int input = m_interpreter->inputs()[0];
|
||||
TfLiteIntArray* input_dims = m_interpreter->tensor(input)->dims;
|
||||
return input_dims->data[1];
|
||||
}
|
||||
|
||||
int GetInputChannels()
|
||||
{
|
||||
int input = m_interpreter->inputs()[0];
|
||||
TfLiteIntArray* input_dims = m_interpreter->tensor(input)->dims;
|
||||
return input_dims->data[3];
|
||||
}
|
||||
|
||||
unsigned int GetNumberOfInputs()
|
||||
{
|
||||
const std::vector<int> inputs = m_interpreter->inputs();
|
||||
return inputs.size();
|
||||
}
|
||||
|
||||
unsigned int GetNumberOfOutputs()
|
||||
{
|
||||
const std::vector<int> outputs = m_interpreter->outputs();
|
||||
return outputs.size();
|
||||
}
|
||||
|
||||
unsigned int GetOutputSize(int index)
|
||||
{
|
||||
int output = m_interpreter->outputs()[index];
|
||||
TfLiteIntArray* output_dims = m_interpreter->tensor(output)->dims;
|
||||
// assume output dims to be something like (1, 1, ... ,size)
|
||||
return output_dims->data[output_dims->size - 1];
|
||||
}
|
||||
|
||||
void RunInference(uint8_t* img, Label_Results* results)
|
||||
{
|
||||
if (m_inputFloating)
|
||||
RunInference<float>(img, results);
|
||||
else
|
||||
RunInference<uint8_t>(img, results);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void RunInference(uint8_t* img, Label_Results* results)
|
||||
{
|
||||
int input_height = GetInputHeight();
|
||||
int input_width = GetInputWidth();
|
||||
int input_channels = GetInputChannels();
|
||||
auto sizeInBytes = input_height * input_width * input_channels;
|
||||
|
||||
int input = m_interpreter->inputs()[0];
|
||||
if (m_verbose) {
|
||||
LOG(INFO) << "input: " << input << "\n";
|
||||
LOG(INFO) << "number of inputs: " << GetNumberOfInputs() << "\n";
|
||||
LOG(INFO) << "number of outputs: " << GetNumberOfOutputs() << "\n";
|
||||
}
|
||||
|
||||
if (m_interpreter->AllocateTensors() != kTfLiteOk) {
|
||||
LOG(FATAL) << "Failed to allocate tensors!";
|
||||
}
|
||||
|
||||
if (m_verbose)
|
||||
tflite::PrintInterpreterState(m_interpreter.get());
|
||||
|
||||
auto in = m_interpreter->typed_tensor<T>(input);
|
||||
if (m_inputFloating) {
|
||||
for (int i = 0; i < sizeInBytes; i++)
|
||||
in[i] = (img[i] - m_inputMean) / m_inputStd;
|
||||
} else {
|
||||
for (int i = 0; i < sizeInBytes; i++)
|
||||
in[i] = img[i];
|
||||
}
|
||||
|
||||
struct timeval start_time, stop_time;
|
||||
gettimeofday(&start_time, nullptr);
|
||||
if (m_interpreter->Invoke() != kTfLiteOk) {
|
||||
LOG(FATAL) << "Failed to invoke tflite!\n";
|
||||
}
|
||||
|
||||
gettimeofday(&stop_time, nullptr);
|
||||
m_inferenceTime = (get_ms(stop_time) - get_ms(start_time));
|
||||
|
||||
/* Get results */
|
||||
T* output = m_interpreter->typed_output_tensor<T>(0);
|
||||
auto output_size = GetOutputSize(0);
|
||||
for (int i = 0; i < m_numberOfResults; i++) {
|
||||
results->index[i] = std::distance(&output[0], std::max_element(&output[0], &output[output_size]));
|
||||
if (m_inputFloating)
|
||||
results->accuracy[i] = output[results->index[i]];
|
||||
else
|
||||
results->accuracy[i] = output[results->index[i]] / 255.0;
|
||||
|
||||
output[results->index[i]] = 0;
|
||||
}
|
||||
results->inference_time = m_inferenceTime;
|
||||
}
|
||||
|
||||
// Takes a file name, and loads a list of labels from it, one per line, and
|
||||
// returns a vector of the strings. It pads with empty strings so the length
|
||||
// of the result is a multiple of 16, because our model expects that.
|
||||
TfLiteStatus ReadLabelsFile(const std::string& file_name,
|
||||
std::vector<std::string>* result,
|
||||
size_t* found_label_count)
|
||||
{
|
||||
std::ifstream file(file_name);
|
||||
if (!file) {
|
||||
LOG(FATAL) << "Labels file " << file_name << " not found\n";
|
||||
return kTfLiteError;
|
||||
}
|
||||
result->clear();
|
||||
std::string line;
|
||||
while (std::getline(file, line)) {
|
||||
result->push_back(line);
|
||||
}
|
||||
*found_label_count = result->size();
|
||||
const int padding = 16;
|
||||
while (result->size() % padding) {
|
||||
result->emplace_back();
|
||||
}
|
||||
return kTfLiteOk;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace wrapper_tfl
|
||||
|
||||
#endif // WRAPPER_TFL_HPP_
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
# Copyright (C) 2019, STMicroelectronics - All Rights Reserved
|
||||
SUMMARY = "Create package containing MobileNetV1 models for EdgeTPU "
|
||||
LICENSE = "Apache-2.0"
|
||||
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
|
||||
|
||||
SRC_URI = " https://raw.githubusercontent.com/google-coral/edgetpu/master/test_data/mobilenet_v1_1.0_224_quant_edgetpu.tflite;subdir=${BPN}-${PV}/mobilenet_v1_1.0_224_quant_edgetpu;name=mobilenet_v1_1.0_224_quant_edgetpu.tflite"
|
||||
SRC_URI[mobilenet_v1_1.0_224_quant_edgetpu.tflite.md5sum] = "06b5764f4a5063903cac48c9fc96d8e5"
|
||||
SRC_URI[mobilenet_v1_1.0_224_quant_edgetpu.tflite.sha256sum] = "e17124a57e78f51af6600a561a76cc13866ab9d039378b3dc83507941957f4b0"
|
||||
|
||||
S = "${WORKDIR}/${BPN}-${PV}"
|
||||
|
||||
do_configure[noexec] = "1"
|
||||
do_compile[noexec] = "1"
|
||||
|
||||
do_install() {
|
||||
install -d ${D}${prefix}/local/demo-ai/image-classification/models/mobilenet
|
||||
|
||||
# install mobilenet models
|
||||
install -m 0644 ${S}/mobilenet_v1_1.0_224_quant_edgetpu/*.tflite ${D}${prefix}/local/demo-ai/image-classification/models/mobilenet/
|
||||
}
|
||||
|
||||
FILES:${PN} += "${prefix}/local/"
|
||||
|
||||
RDEPENDS:${PN} += " tflite-models-mobilenetv1 "
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -1,26 +0,0 @@
|
|||
# Copyright (C) 2019, STMicroelectronics - All Rights Reserved
|
||||
SUMMARY = "Create package containing MobileNetV1 models"
|
||||
LICENSE = "Apache-2.0"
|
||||
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
|
||||
|
||||
#NBG model files need to be pre-compiled using STM32AI-MPU offline compiler tool.
|
||||
#This package contain an example compiled for gcnano driver 6.4.13
|
||||
|
||||
SRC_URI = " file://mobilenet_v3_large_100_224_quant.nb \
|
||||
file://labels_mobilenet_nbg.txt "
|
||||
|
||||
S = "${WORKDIR}"
|
||||
|
||||
do_configure[noexec] = "1"
|
||||
do_compile[noexec] = "1"
|
||||
|
||||
do_install() {
|
||||
install -d ${D}${prefix}/local/demo-ai/image-classification/models/mobilenet
|
||||
install -d ${D}${prefix}/local/demo-ai/image-classification/models/mobilenet/testdata
|
||||
|
||||
# install mobilenet models
|
||||
install -m 0644 ${S}/labels_mobilenet_nbg.txt ${D}${prefix}/local/demo-ai/image-classification/models/mobilenet/labels_mobilenet_v3_nbg.txt
|
||||
install -m 0644 ${S}/*.nb ${D}${prefix}/local/demo-ai/image-classification/models/mobilenet/
|
||||
}
|
||||
|
||||
FILES:${PN} += "${prefix}/local/"
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
# Copyright (C) 2019, STMicroelectronics - All Rights Reserved
|
||||
SUMMARY = "Create package containing MobileNetV1/2 models"
|
||||
LICENSE = "Apache-2.0"
|
||||
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
|
||||
|
||||
# These models are not available in the onnx/models repository and integrating the tf2onnx
|
||||
# converter in the yocto workflow (to convert them from tflite) would require integrating
|
||||
# tensorflow (not lite) and bazel as well, which is a pretty big undertaking.
|
||||
# So, for now, we will simply include the converted models manually.
|
||||
|
||||
SRC_URI = " file://mobilenet_v1_0.5_128.onnx \
|
||||
file://mobilenet_v1_0.5_128_quant.onnx \
|
||||
file://mobilenet_v1_1.0_224_quant.onnx \
|
||||
file://labels_mobilenet_onnx.txt "
|
||||
|
||||
S = "${WORKDIR}"
|
||||
|
||||
do_configure[noexec] = "1"
|
||||
do_compile[noexec] = "1"
|
||||
|
||||
do_install() {
|
||||
install -d ${D}${prefix}/local/demo-ai/image-classification/models/mobilenet
|
||||
install -d ${D}${prefix}/local/demo-ai/image-classification/models/mobilenet/testdata
|
||||
|
||||
# install mobilenet models
|
||||
install -m 0644 ${S}/label*.txt ${D}${prefix}/local/demo-ai/image-classification/models/mobilenet/labels_onnx.txt
|
||||
install -m 0644 ${S}/*.onnx ${D}${prefix}/local/demo-ai/image-classification/models/mobilenet/
|
||||
}
|
||||
|
||||
FILES:${PN} += "${prefix}/local/"
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
# Copyright (C) 2019, STMicroelectronics - All Rights Reserved
|
||||
SUMMARY = "Create package containing MobileNetV1/2 models"
|
||||
LICENSE = "Apache-2.0"
|
||||
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
|
||||
|
||||
# These models are not available in the onnx/models repository and integrating the tf2onnx
|
||||
# converter in the yocto workflow (to convert them from tflite) would require integrating
|
||||
# tensorflow (not lite) and bazel as well, which is a pretty big undertaking.
|
||||
# So, for now, we will simply include the converted models manually.
|
||||
|
||||
SRC_URI = " file://mobilenet_v3_large_100_224_quant.onnx \
|
||||
file://labels_mobilenet_onnx.txt "
|
||||
|
||||
S = "${WORKDIR}"
|
||||
|
||||
do_configure[noexec] = "1"
|
||||
do_compile[noexec] = "1"
|
||||
|
||||
do_install() {
|
||||
install -d ${D}${prefix}/local/demo-ai/image-classification/models/mobilenet
|
||||
install -d ${D}${prefix}/local/demo-ai/image-classification/models/mobilenet/testdata
|
||||
|
||||
# install mobilenet models
|
||||
install -m 0644 ${S}/label*.txt ${D}${prefix}/local/demo-ai/image-classification/models/mobilenet/labels_mobilenet_v3_onnx.txt
|
||||
install -m 0644 ${S}/*.onnx ${D}${prefix}/local/demo-ai/image-classification/models/mobilenet/
|
||||
}
|
||||
|
||||
FILES:${PN} += "${prefix}/local/"
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
# Copyright (C) 2019, STMicroelectronics - All Rights Reserved
|
||||
SUMMARY = "Create package containing MobileNetV1 models"
|
||||
LICENSE = "Apache-2.0"
|
||||
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
|
||||
|
||||
SRC_URI = " https://storage.googleapis.com/download.tensorflow.org/models/tflite/mobilenet_v1_1.0_224_quant_and_labels.zip;subdir=${BPN}-${PV}/mobilenet_v1_1.0_224_quant;name=mobilenet_v1_1.0_224_quant "
|
||||
SRC_URI[mobilenet_v1_1.0_224_quant.md5sum] = "38ac0c626947875bd311ef96c8baab62"
|
||||
SRC_URI[mobilenet_v1_1.0_224_quant.sha256sum] = "2f8054076cf655e1a73778a49bd8fd0306d32b290b7e576dda9574f00f186c0f"
|
||||
|
||||
SRC_URI += " https://storage.googleapis.com/download.tensorflow.org/models/mobilenet_v1_2018_08_02/mobilenet_v1_0.5_128_quant.tgz;subdir=${BPN}-${PV}/mobilenet_v1_0.5_128_quant;name=mobilenet_v1_0.5_128_quant "
|
||||
SRC_URI[mobilenet_v1_0.5_128_quant.md5sum] = "5cc8484cf04a407fc90993296f3f02db"
|
||||
SRC_URI[mobilenet_v1_0.5_128_quant.sha256sum] = "0a5b18571d3df4d85a5ac6cb5be829d141dd5855243ea04422ca7d19f730a506"
|
||||
|
||||
SRC_URI += " https://storage.googleapis.com/download.tensorflow.org/models/mobilenet_v1_2018_02_22/mobilenet_v1_0.5_128.tgz;subdir=${BPN}-${PV}/mobilenet_v1_0.5_128_float;name=mobilenet_v1_0.5_128_float "
|
||||
SRC_URI[mobilenet_v1_0.5_128_float.md5sum] = "1950d02e12e2c85613c6f973b1213d1b"
|
||||
SRC_URI[mobilenet_v1_0.5_128_float.sha256sum] = "5a0def0d844327526385b110cdcaa6428d0828ff6d07515ef25bf3976e049d88"
|
||||
|
||||
S = "${WORKDIR}/${BPN}-${PV}"
|
||||
|
||||
do_configure[noexec] = "1"
|
||||
do_compile[noexec] = "1"
|
||||
|
||||
do_install() {
|
||||
install -d ${D}${prefix}/local/demo-ai/image-classification/models/mobilenet
|
||||
install -d ${D}${prefix}/local/demo-ai/image-classification/models/mobilenet/testdata
|
||||
|
||||
# install mobilenet models
|
||||
install -m 0644 ${S}/mobilenet_v1_1.0_224_quant/label*.txt ${D}${prefix}/local/demo-ai/image-classification/models/mobilenet/labels.txt
|
||||
install -m 0644 ${S}/mobilenet_v1_1.0_224_quant/*.tflite ${D}${prefix}/local/demo-ai/image-classification/models/mobilenet/
|
||||
install -m 0644 ${S}/mobilenet_v1_0.5_128_quant/*.tflite ${D}${prefix}/local/demo-ai/image-classification/models/mobilenet/
|
||||
install -m 0644 ${S}/mobilenet_v1_0.5_128_float/*.tflite ${D}${prefix}/local/demo-ai/image-classification/models/mobilenet/
|
||||
}
|
||||
|
||||
FILES:${PN} += "${prefix}/local/"
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
# Copyright (C) 2019, STMicroelectronics - All Rights Reserved
|
||||
SUMMARY = "Create package containing MobileNetV3 model"
|
||||
LICENSE = "Apache-2.0"
|
||||
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
|
||||
|
||||
SRC_URI = " https://tfhub.dev/iree/lite-model/mobilenet_v3_large_100_224/uint8/1?lite-format=tflite;subdir=mobilenet_v3_large_100_224_quant;name=mobilenet_v3_large_100_224_quant "
|
||||
SRC_URI += " file://labels_mobilenet_tflite.txt "
|
||||
|
||||
SRC_URI[mobilenet_v3_large_100_224_quant.md5sum] = "68451f4fdc681bca5c548c595386b918"
|
||||
SRC_URI[mobilenet_v3_large_100_224_quant.sha256sum] = "78c5eddce8533ca95b4d122ec291694263b91c285616a9487f470c6a930a63cd"
|
||||
|
||||
S = "${WORKDIR}"
|
||||
|
||||
do_configure[noexec] = "1"
|
||||
do_compile[noexec] = "1"
|
||||
|
||||
do_install() {
|
||||
install -d ${D}${prefix}/local/demo-ai/image-classification/models/mobilenet
|
||||
install -d ${D}${prefix}/local/demo-ai/image-classification/models/mobilenet/testdata
|
||||
|
||||
#the model is fetched with a bad name -> rename it before installation
|
||||
mv ${S}/mobilenet_v3_large_100_224_quant/1\?lite-format\=tflite ${S}/mobilenet_v3_large_100_224_quant/mobilenet_v3_large_100_224_quant.tflite
|
||||
# install mobilenetV3 model + corresponding label file
|
||||
install -m 0644 ${S}/label*.txt ${D}${prefix}/local/demo-ai/image-classification/models/mobilenet/labels_mobilenet_v3.txt
|
||||
install -m 0644 ${S}/mobilenet_v3_large_100_224_quant/*.tflite ${D}${prefix}/local/demo-ai/image-classification/models/mobilenet/
|
||||
|
||||
}
|
||||
|
||||
FILES:${PN} += "${prefix}/local/"
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
# Copyright (C) 2024, Digi International Inc.
|
||||
|
||||
SRC_URI:remove = "https://tfhub.dev/iree/lite-model/mobilenet_v3_large_100_224/uint8/1?lite-format=tflite;subdir=mobilenet_v3_large_100_224_quant;name=mobilenet_v3_large_100_224_quant"
|
||||
SRC_URI:append = "file://mobilenet_v3_large_100_224_quant.tflite"
|
||||
|
||||
do_install() {
|
||||
install -d ${D}${prefix}/local/demo-ai/image-classification/models/mobilenet
|
||||
install -d ${D}${prefix}/local/demo-ai/image-classification/models/mobilenet/testdata
|
||||
|
||||
# install mobilenetV3 model + corresponding label file
|
||||
install -m 0644 ${S}/label*.txt ${D}${prefix}/local/demo-ai/image-classification/models/mobilenet/labels_mobilenet_v3.txt
|
||||
install -m 0644 ${WORKDIR}/mobilenet_v3_large_100_224_quant.tflite ${D}${prefix}/local/demo-ai/image-classification/models/mobilenet/
|
||||
}
|
||||
|
|
@ -1,64 +0,0 @@
|
|||
# Copyright (C) 2023, STMicroelectronics - All Rights Reserved
|
||||
SUMMARY = "NBG C++ Computer Vision image classification application example"
|
||||
LICENSE = "BSD-3-Clause"
|
||||
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/BSD-3-Clause;md5=550794465ba0ec5312d6919e203a55f9"
|
||||
|
||||
inherit pkgconfig
|
||||
|
||||
COMPATIBLE_MACHINE = "stm32mp25common"
|
||||
|
||||
DEPENDS += "jpeg gcnano-driver-stm32mp gcnano-userland opencv gstreamer1.0-plugins-base gstreamer1.0-plugins-bad "
|
||||
|
||||
SRC_URI = " file://nbg;subdir=${BPN}-${PV} "
|
||||
|
||||
S = "${WORKDIR}/${BPN}-${PV}"
|
||||
|
||||
do_configure[noexec] = "1"
|
||||
|
||||
EXTRA_OEMAKE = 'SYSROOT="${RECIPE_SYSROOT}"'
|
||||
|
||||
do_compile() {
|
||||
#Check the version of OpenCV and fill OPENCV_VERSION accordingly
|
||||
FILE=${RECIPE_SYSROOT}/${libdir}/pkgconfig/opencv4.pc
|
||||
if [ -f "$FILE" ]; then
|
||||
OPENCV_VERSION=opencv4
|
||||
else
|
||||
OPENCV_VERSION=opencv
|
||||
fi
|
||||
|
||||
oe_runmake OPENCV_PKGCONFIG=${OPENCV_VERSION} NEW_GST_WAYLAND_API=${NEW_GST_WAYLAND_API} -C ${S}/nbg/
|
||||
}
|
||||
|
||||
do_install() {
|
||||
install -d ${D}${prefix}/local/demo/application
|
||||
install -d ${D}${prefix}/local/demo-ai/image-classification/nbg
|
||||
|
||||
# install applications into the demo launcher
|
||||
install -m 0755 ${S}/nbg/130-nbg-image-classification-C++.yaml ${D}${prefix}/local/demo/application
|
||||
|
||||
# install application binaries and launcher scripts
|
||||
install -m 0755 ${S}/nbg/nbg_image_classification ${D}${prefix}/local/demo-ai/image-classification/nbg
|
||||
install -m 0755 ${S}/nbg/launch_bin*.sh ${D}${prefix}/local/demo-ai/image-classification/nbg
|
||||
}
|
||||
|
||||
FILES:${PN} += "${prefix}/local/"
|
||||
|
||||
INSANE_SKIP:${PN} = "ldflags"
|
||||
|
||||
RDEPENDS:${PN} += " \
|
||||
gstreamer1.0-plugins-bad-waylandsink \
|
||||
gstreamer1.0-plugins-bad-debugutilsbad \
|
||||
gstreamer1.0-plugins-base-app \
|
||||
gstreamer1.0-plugins-base-videorate \
|
||||
gstreamer1.0-plugins-good-video4linux2 \
|
||||
gtk+3 \
|
||||
libopencv-core \
|
||||
libopencv-imgproc \
|
||||
libopencv-imgcodecs \
|
||||
application-resources \
|
||||
nbg-models-mobilenetv3 \
|
||||
bash \
|
||||
"
|
||||
|
||||
#Depending of the Gstreamer version supported by the Yocto version the RDEPENDS differs
|
||||
RDEPENDS:${PN} += "${@bb.utils.contains('DISTRO_CODENAME', 'kirkstone', ' gstreamer1.0-plugins-base-videoscale gstreamer1.0-plugins-base-videoconvert ', ' gstreamer1.0-plugins-base-videoconvertscale ', d)}"
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
# Copyright (C) 2022, STMicroelectronics - All Rights Reserved
|
||||
SUMMARY = "OnnxRuntime Python Computer Vision image classification application example"
|
||||
LICENSE = "BSD-3-Clause"
|
||||
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/BSD-3-Clause;md5=550794465ba0ec5312d6919e203a55f9"
|
||||
|
||||
SRC_URI = " file://onnx;subdir=${BPN}-${PV} "
|
||||
|
||||
S = "${WORKDIR}/${BPN}-${PV}"
|
||||
|
||||
do_configure[noexec] = "1"
|
||||
do_compile[noexec] = "1"
|
||||
|
||||
do_install() {
|
||||
install -d ${D}${prefix}/local/demo/application
|
||||
install -d ${D}${prefix}/local/demo-ai/image-classification/onnx
|
||||
|
||||
# install applications into the demo launcher
|
||||
install -m 0755 ${S}/onnx/120-onnx-image-classification-python.yaml ${D}${prefix}/local/demo/application
|
||||
|
||||
# install application binaries and launcher scripts
|
||||
install -m 0755 ${S}/onnx/onnx_image_classification.py ${D}${prefix}/local/demo-ai/image-classification/onnx
|
||||
install -m 0755 ${S}/onnx/launch_python*.sh ${D}${prefix}/local/demo-ai/image-classification/onnx
|
||||
}
|
||||
|
||||
do_install:append:stm32mp25common(){
|
||||
install -m 0755 ${S}/onnx/120-onnx-image-classification-python-mp2.yaml ${D}${prefix}/local/demo/application/120-onnx-image-classification-python.yaml
|
||||
}
|
||||
|
||||
FILES:${PN} += "${prefix}/local/"
|
||||
|
||||
RDEPENDS:${PN} += " \
|
||||
python3-core \
|
||||
python3-numpy \
|
||||
python3-opencv \
|
||||
python3-pillow \
|
||||
python3-pygobject \
|
||||
python3-onnxruntime \
|
||||
application-resources \
|
||||
bash \
|
||||
"
|
||||
|
||||
RDEPENDS:${PN}:append:stm32mp25common = " onnx-models-mobilenetv3 "
|
||||
RDEPENDS:${PN}:append:stm32mp1common = " onnx-models-mobilenetv1 "
|
||||
|
|
@ -1,76 +0,0 @@
|
|||
# Copyright (C) 2022, STMicroelectronics - All Rights Reserved
|
||||
SUMMARY = "TensorFlowLite C++ API Computer Vision image classification application example"
|
||||
LICENSE = "BSD-3-Clause & Apache-2.0"
|
||||
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/BSD-3-Clause;md5=550794465ba0ec5312d6919e203a55f9"
|
||||
LIC_FILES_CHKSUM += "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
|
||||
|
||||
inherit pkgconfig
|
||||
|
||||
DEPENDS += " tensorflow-lite gtk+3 opencv gstreamer1.0-plugins-base gstreamer1.0-plugins-bad"
|
||||
DEPENDS:append:stm32mp25common = " tflite-vx-delegate"
|
||||
|
||||
SRC_URI = " file://tflite;subdir=${BPN}-${PV} "
|
||||
|
||||
S = "${WORKDIR}/${BPN}-${PV}"
|
||||
|
||||
do_configure[noexec] = "1"
|
||||
|
||||
BOARD_USED:stm32mp1common = "stm32mp1"
|
||||
BOARD_USED:stm32mp25common = "stm32mp2_npu"
|
||||
|
||||
EXTRA_OEMAKE = 'SYSROOT="${RECIPE_SYSROOT}"'
|
||||
EXTRA_OEMAKE += 'ARCHITECTURE="${BOARD_USED}"'
|
||||
|
||||
do_compile() {
|
||||
#Check the version of OpenCV and fill OPENCV_VERSION accordingly
|
||||
FILE=${RECIPE_SYSROOT}/${libdir}/pkgconfig/opencv4.pc
|
||||
if [ -f "$FILE" ]; then
|
||||
OPENCV_VERSION=opencv4
|
||||
else
|
||||
OPENCV_VERSION=opencv
|
||||
fi
|
||||
|
||||
oe_runmake OPENCV_PKGCONFIG=${OPENCV_VERSION} -C ${S}/tflite/
|
||||
}
|
||||
|
||||
do_install() {
|
||||
install -d ${D}${prefix}/local/demo/application
|
||||
install -d ${D}${prefix}/local/demo-ai/image-classification/tflite
|
||||
|
||||
# install applications into the demo launcher
|
||||
install -m 0755 ${S}/tflite/101-tflite-image-classification-cpp.yaml ${D}${prefix}/local/demo/application
|
||||
|
||||
# install application binaries and launcher scripts
|
||||
install -m 0755 ${S}/tflite/tflite_image_classification ${D}${prefix}/local/demo-ai/image-classification/tflite
|
||||
install -m 0755 ${S}/tflite/launch_bin*.sh ${D}${prefix}/local/demo-ai/image-classification/tflite
|
||||
}
|
||||
|
||||
do_install:append:stm32mp25common(){
|
||||
install -m 0755 ${S}/tflite/101-tflite-image-classification-cpp-mp2.yaml ${D}${prefix}/local/demo/application/101-tflite-image-classification-cpp.yaml
|
||||
}
|
||||
|
||||
FILES:${PN} += "${prefix}/local/"
|
||||
|
||||
INSANE_SKIP:${PN} = "ldflags"
|
||||
|
||||
RDEPENDS:${PN} += " \
|
||||
gstreamer1.0-plugins-bad-waylandsink \
|
||||
gstreamer1.0-plugins-bad-debugutilsbad \
|
||||
gstreamer1.0-plugins-base-app \
|
||||
gstreamer1.0-plugins-base-videorate \
|
||||
gstreamer1.0-plugins-good-video4linux2 \
|
||||
gstreamer1.0-plugins-base-videoconvertscale \
|
||||
gtk+3 \
|
||||
libopencv-core \
|
||||
libopencv-imgproc \
|
||||
libopencv-imgcodecs \
|
||||
tensorflow-lite \
|
||||
application-resources \
|
||||
bash \
|
||||
"
|
||||
|
||||
#Depending of the Gstreamer version supported by the Yocto version the RDEPENDS differs
|
||||
RDEPENDS:${PN} += "${@bb.utils.contains('DISTRO_CODENAME', 'kirkstone', ' gstreamer1.0-plugins-base-videoscale gstreamer1.0-plugins-base-videoconvert ', ' gstreamer1.0-plugins-base-videoconvertscale ', d)}"
|
||||
RDEPENDS:${PN}:append:stm32mp25common = " tflite-models-mobilenetv3 "
|
||||
RDEPENDS:${PN}:append:stm32mp25common = " nbg-models-mobilenetv3 "
|
||||
RDEPENDS:${PN}:append:stm32mp1common = " tflite-models-mobilenetv1 "
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
# Copyright (C) 2022, STMicroelectronics - All Rights Reserved
|
||||
SUMMARY = "TensorFlowLite Python Computer Vision image classification application example"
|
||||
LICENSE = "BSD-3-Clause"
|
||||
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/BSD-3-Clause;md5=550794465ba0ec5312d6919e203a55f9"
|
||||
|
||||
SRC_URI = " file://tflite;subdir=${BPN}-${PV} "
|
||||
|
||||
S = "${WORKDIR}/${BPN}-${PV}"
|
||||
|
||||
do_configure[noexec] = "1"
|
||||
do_compile[noexec] = "1"
|
||||
|
||||
do_install() {
|
||||
install -d ${D}${prefix}/local/demo/application
|
||||
install -d ${D}${prefix}/local/demo-ai/image-classification/tflite
|
||||
|
||||
# install applications into the demo launcher
|
||||
install -m 0755 ${S}/tflite/100-tflite-image-classification-python.yaml ${D}${prefix}/local/demo/application
|
||||
|
||||
# install application binaries and launcher scripts
|
||||
install -m 0755 ${S}/tflite/tflite_image_classification.py ${D}${prefix}/local/demo-ai/image-classification/tflite
|
||||
install -m 0755 ${S}/tflite/launch_python*.sh ${D}${prefix}/local/demo-ai/image-classification/tflite
|
||||
}
|
||||
|
||||
do_install:append:stm32mp25common(){
|
||||
install -m 0755 ${S}/tflite/100-tflite-image-classification-python-mp2.yaml ${D}${prefix}/local/demo/application/100-tflite-image-classification-python.yaml
|
||||
}
|
||||
|
||||
FILES:${PN} += "${prefix}/local/"
|
||||
|
||||
RDEPENDS:${PN} += " \
|
||||
python3-core \
|
||||
python3-numpy \
|
||||
python3-opencv \
|
||||
python3-pillow \
|
||||
python3-pygobject \
|
||||
python3-tensorflow-lite \
|
||||
application-resources \
|
||||
bash \
|
||||
"
|
||||
|
||||
RDEPENDS:${PN}:append:stm32mp25common = " tflite-models-mobilenetv3 "
|
||||
RDEPENDS:${PN}:append:stm32mp25common = " nbg-models-mobilenetv3 "
|
||||
RDEPENDS:${PN}:append:stm32mp1common = " tflite-models-mobilenetv1 "
|
||||
|
|
@ -1,63 +0,0 @@
|
|||
# Copyright (C) 2020, STMicroelectronics - All Rights Reserved
|
||||
SUMMARY = "TensorFlowLite C++ API Computer Vision object detection application example running on the EdgeTPU"
|
||||
LICENSE = "BSD-3-Clause & Apache-2.0"
|
||||
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/BSD-3-Clause;md5=550794465ba0ec5312d6919e203a55f9"
|
||||
LIC_FILES_CHKSUM += "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
|
||||
|
||||
inherit pkgconfig
|
||||
|
||||
DEPENDS += "tensorflow-lite libedgetpu gtk+3 opencv gstreamer1.0 rapidjson gstreamer1.0-plugins-base gstreamer1.0-plugins-bad "
|
||||
|
||||
SRC_URI = " file://tflite;subdir=${BPN}-${PV} "
|
||||
|
||||
S = "${WORKDIR}/${BPN}-${PV}"
|
||||
|
||||
do_configure[noexec] = "1"
|
||||
|
||||
EXTRA_OEMAKE = 'SYSROOT="${RECIPE_SYSROOT}"'
|
||||
EXTRA_OEMAKE += 'EDGETPU=TRUE'
|
||||
|
||||
do_compile() {
|
||||
#Check the version of OpenCV and fill OPENCV_VERSION accordingly
|
||||
FILE=${RECIPE_SYSROOT}/${libdir}/pkgconfig/opencv4.pc
|
||||
if [ -f "$FILE" ]; then
|
||||
OPENCV_VERSION=opencv4
|
||||
else
|
||||
OPENCV_VERSION=opencv
|
||||
fi
|
||||
|
||||
oe_runmake OPENCV_PKGCONFIG=${OPENCV_VERSION} -C ${S}/tflite/
|
||||
}
|
||||
|
||||
do_install() {
|
||||
install -d ${D}${prefix}/local/demo/application
|
||||
install -d ${D}${prefix}/local/demo-ai/object-detection/coral
|
||||
|
||||
# install applications into the demo launcher
|
||||
install -m 0755 ${S}/tflite/211-coral-object-detection-C++.yaml ${D}${prefix}/local/demo/application
|
||||
|
||||
# install application binaries and launcher scripts
|
||||
install -m 0755 ${S}/tflite/tflite_object_detection ${D}${prefix}/local/demo-ai/object-detection/coral/coral_object_detection
|
||||
install -m 0755 ${S}/tflite/launch_coral_bin*.sh ${D}${prefix}/local/demo-ai/object-detection/coral
|
||||
}
|
||||
|
||||
FILES:${PN} += "${prefix}/local/"
|
||||
|
||||
INSANE_SKIP:${PN} = "ldflags"
|
||||
|
||||
RDEPENDS:${PN} += " \
|
||||
gstreamer1.0-plugins-bad-waylandsink \
|
||||
gstreamer1.0-plugins-bad-debugutilsbad \
|
||||
gstreamer1.0-plugins-base-app \
|
||||
gstreamer1.0-plugins-base-videorate \
|
||||
gstreamer1.0-plugins-good-video4linux2 \
|
||||
gstreamer1.0-plugins-base-videoconvertscale \
|
||||
gtk+3 \
|
||||
libedgetpu \
|
||||
libopencv-core \
|
||||
libopencv-imgproc \
|
||||
libopencv-imgcodecs \
|
||||
coral-models-coco-ssd-mobilenetv1 \
|
||||
application-resources \
|
||||
bash \
|
||||
"
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
# Copyright (C) 2022, STMicroelectronics - All Rights Reserved
|
||||
SUMMARY = "TensorFlowLite Python Computer Vision object detection application examples running on the EdgeTPU"
|
||||
LICENSE = "BSD-3-Clause"
|
||||
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/BSD-3-Clause;md5=550794465ba0ec5312d6919e203a55f9"
|
||||
|
||||
SRC_URI = " file://tflite;subdir=${BPN}-${PV} "
|
||||
|
||||
S = "${WORKDIR}/${BPN}-${PV}"
|
||||
|
||||
do_configure[noexec] = "1"
|
||||
do_compile[noexec] = "1"
|
||||
|
||||
do_install() {
|
||||
install -d ${D}${prefix}/local/demo/application
|
||||
install -d ${D}${prefix}/local/demo-ai/object-detection/coral
|
||||
|
||||
# install applications into the demo launcher
|
||||
install -m 0755 ${S}/tflite/210-coral-object-detection-python.yaml ${D}${prefix}/local/demo/application
|
||||
|
||||
# install application binaries and launcher scripts
|
||||
install -m 0755 ${S}/tflite/tflite_object_detection.py ${D}${prefix}/local/demo-ai/object-detection/coral/coral_object_detection.py
|
||||
install -m 0755 ${S}/tflite/launch_coral_python*.sh ${D}${prefix}/local/demo-ai/object-detection/coral
|
||||
}
|
||||
|
||||
FILES:${PN} += "${prefix}/local/"
|
||||
|
||||
RDEPENDS:${PN} += " \
|
||||
python3-core \
|
||||
python3-numpy \
|
||||
python3-opencv \
|
||||
python3-pillow \
|
||||
python3-pygobject \
|
||||
python3-tensorflow-lite \
|
||||
libedgetpu \
|
||||
coral-models-coco-ssd-mobilenetv1 \
|
||||
application-resources \
|
||||
bash \
|
||||
"
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
Application:
|
||||
Name: Object Detection
|
||||
Description: COCO SSD v1
|
||||
Icon: ../demo-ai/resources/onnx_python.png
|
||||
Board:
|
||||
List: all
|
||||
Type: script
|
||||
Script:
|
||||
Exist:
|
||||
File: /usr/local/demo-ai/resources/check_camera_preview.sh
|
||||
Msg_false: Camera is not connected
|
||||
Start: ../demo-ai/object-detection/onnx/launch_python_object_detection.sh
|
||||
Action:
|
||||
button_release_event: script_management
|
||||
button_press_event: highlight_eventBox
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
Application:
|
||||
Name: Object Detection
|
||||
Description: COCO SSD v1
|
||||
Icon: ../demo-ai/resources/onnx_cpp.png
|
||||
Board:
|
||||
List: all
|
||||
Type: script
|
||||
Script:
|
||||
Exist:
|
||||
File: /usr/local/demo-ai/resources/check_camera_preview.sh
|
||||
Msg_false: Camera is not connected
|
||||
Start: ../demo-ai/object-detection/onnx/launch_bin_object_detection.sh
|
||||
Action:
|
||||
button_release_event: script_management
|
||||
button_press_event: highlight_eventBox
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
OPENCV_PKGCONFIG?="opencv4"
|
||||
SYSROOT?=""
|
||||
TARGET_BIN = onnx_object_detection
|
||||
|
||||
CXXFLAGS += -Wall $(shell pkg-config --cflags gtk+-3.0 $(OPENCV_PKGCONFIG) gstreamer-plugins-base-1.0 gstreamer-wayland-1.0)
|
||||
CXXFLAGS += -std=c++17
|
||||
CXXFLAGS += -I$(SYSROOT)/usr/include/rapidjson
|
||||
CXXFLAGS += -I$(SYSROOT)/usr/include/onnxruntime
|
||||
CXXFLAGS += -I$(SYSROOT)/usr/include/onnxruntime/core/session
|
||||
|
||||
LDFLAGS = $(shell pkg-config --libs gtk+-3.0 gstreamer-plugins-base-1.0 gstreamer-wayland-1.0)
|
||||
LDFLAGS += -lpthread -ldl -lopencv_core -lopencv_imgproc -lopencv_imgcodecs -lonnxruntime
|
||||
|
||||
SRCS = onnx_object_detection.cc
|
||||
OBJS = $(SRCS:.cc=.o)
|
||||
|
||||
all: $(TARGET_BIN)
|
||||
|
||||
$(TARGET_BIN): $(OBJS)
|
||||
$(CXX) $(LDFLAGS) -o $@ $^
|
||||
|
||||
$(OBJS): $(SRCS)
|
||||
$(CXX) $(CXXFLAGS) -c $^
|
||||
|
||||
clean:
|
||||
rm -rf $(OBJS) $(TARGET_BIN)
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
#!/bin/sh
|
||||
weston_user=$(ps aux | grep '/usr/bin/weston '|grep -v 'grep'|awk '{print $1}')
|
||||
source /usr/local/demo-ai/resources/config_board.sh
|
||||
cmd="/usr/local/demo-ai/object-detection/onnx/onnx_object_detection -m /usr/local/demo-ai/object-detection/models/coco_ssd_mobilenet/coco_ssd_mobilenet.onnx -l /usr/local/demo-ai/object-detection/models/coco_ssd_mobilenet/labels_coco_ssd_mobilenet_onnx.txt --framerate $DFPS --frame_width $DWIDTH --frame_height $DHEIGHT"
|
||||
if [ "$weston_user" != "root" ]; then
|
||||
echo "user : "$weston_user
|
||||
script -qc "su -l $weston_user -c '$cmd'"
|
||||
else
|
||||
$cmd
|
||||
fi
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
#!/bin/sh
|
||||
weston_user=$(ps aux | grep '/usr/bin/weston '|grep -v 'grep'|awk '{print $1}')
|
||||
source /usr/local/demo-ai/resources/config_board.sh
|
||||
cmd="/usr/local/demo-ai/object-detection/onnx/onnx_object_detection -m /usr/local/demo-ai/object-detection/models/coco_ssd_mobilenet/coco_ssd_mobilenet.onnx -l /usr/local/demo-ai/object-detection/models/coco_ssd_mobilenet/labels_coco_ssd_mobilenet_onnx.txt -i /usr/local/demo-ai/object-detection/models/coco_ssd_mobilenet/testdata/"
|
||||
if [ "$weston_user" != "root" ]; then
|
||||
echo "user : "$weston_user
|
||||
script -qc "su -l $weston_user -c '$cmd'"
|
||||
else
|
||||
$cmd
|
||||
fi
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
#!/bin/sh
|
||||
weston_user=$(ps aux | grep '/usr/bin/weston '|grep -v 'grep'|awk '{print $1}')
|
||||
source /usr/local/demo-ai/resources/config_board.sh
|
||||
cmd="python3 /usr/local/demo-ai/object-detection/onnx/onnx_object_detection.py -m /usr/local/demo-ai/object-detection/models/coco_ssd_mobilenet/coco_ssd_mobilenet.onnx -l /usr/local/demo-ai/object-detection/models/coco_ssd_mobilenet/labels_coco_ssd_mobilenet_onnx.txt --framerate $DFPS --frame_width $DWIDTH --frame_height $DHEIGHT"
|
||||
if [ "$weston_user" != "root" ]; then
|
||||
echo "user : "$weston_user
|
||||
script -qc "su -l $weston_user -c '$cmd'"
|
||||
else
|
||||
$cmd
|
||||
fi
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
#!/bin/sh
|
||||
weston_user=$(ps aux | grep '/usr/bin/weston '|grep -v 'grep'|awk '{print $1}')
|
||||
source /usr/local/demo-ai/resources/config_board.sh
|
||||
cmd="python3 /usr/local/demo-ai/object-detection/onnx/onnx_object_detection.py -m /usr/local/demo-ai/object-detection/models/coco_ssd_mobilenet/coco_ssd_mobilenet.onnx -l /usr/local/demo-ai/object-detection/models/coco_ssd_mobilenet/labels_coco_ssd_mobilenet_onnx.txt -i /usr/local/demo-ai/object-detection/models/coco_ssd_mobilenet/testdata/"
|
||||
if [ "$weston_user" != "root" ]; then
|
||||
echo "user : "$weston_user
|
||||
script -qc "su -l $weston_user -c '$cmd'"
|
||||
else
|
||||
$cmd
|
||||
fi
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -1,400 +0,0 @@
|
|||
/*
|
||||
* wrapper_onnx.hpp
|
||||
*
|
||||
* Author: Vincent Abriou <vincent.abriou@st.com> for STMicroelectronics.
|
||||
* Co-Author : Youssef Khemakhem <youssef.khemakhem@st.com> for STMicroelectronics.
|
||||
* Copyright (c) 2020 STMicroelectronics. All rights reserved.
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* 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.opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef WRAPPER_ONNX_HPP_
|
||||
#define WRAPPER_ONNX_HPP_
|
||||
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <fstream>
|
||||
#include <queue>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <sys/time.h>
|
||||
#include <vector>
|
||||
#include <cmath>
|
||||
#include <numeric>
|
||||
#include "onnxruntime_cxx_api.h"
|
||||
|
||||
|
||||
|
||||
#define LOG(x) std::cerr
|
||||
|
||||
|
||||
|
||||
namespace wrapper_onnx {
|
||||
|
||||
|
||||
double get_ms(struct timeval t) { return (t.tv_sec * 1000 + t.tv_usec / 1000); }
|
||||
bool first_call = true;
|
||||
struct Config {
|
||||
bool verbose;
|
||||
float input_mean = 127.5f;
|
||||
float input_std = 127.5f;
|
||||
int number_of_threads = 2;
|
||||
int number_of_results = 5;
|
||||
std::string model_name;
|
||||
std::string labels_file_name;
|
||||
|
||||
};
|
||||
|
||||
struct ObjDetect_Location {
|
||||
float y0, x0, y1, x1;
|
||||
};
|
||||
|
||||
struct ObjDetect_Results {
|
||||
int classe;
|
||||
float score;
|
||||
ObjDetect_Location location;
|
||||
};
|
||||
|
||||
struct Frame_Results {
|
||||
std::vector<ObjDetect_Results> vect_ObjDetect_Results;
|
||||
float inference_time;
|
||||
};
|
||||
|
||||
std::nullptr_t t ;
|
||||
|
||||
|
||||
|
||||
class Onnx_Wrapper {
|
||||
private:
|
||||
|
||||
|
||||
Ort::Session m_session ;
|
||||
Ort::AllocatorWithDefaultOptions m_allocator;
|
||||
bool m_verbose;
|
||||
bool m_inputFloating;
|
||||
float m_inputMean;
|
||||
float m_inputStd;
|
||||
float m_inferenceTime;
|
||||
int m_numberOfThreads;
|
||||
int m_numberOfResults;
|
||||
|
||||
|
||||
public:
|
||||
Onnx_Wrapper():m_session(t) {}
|
||||
|
||||
void Initialize(Config* conf)
|
||||
{
|
||||
m_inputFloating = false;
|
||||
m_inferenceTime = 0;
|
||||
m_verbose = conf->verbose;
|
||||
m_inputMean = conf->input_mean;
|
||||
m_inputStd = conf->input_std;
|
||||
m_numberOfThreads = conf->number_of_threads;
|
||||
m_numberOfResults = conf->number_of_results;
|
||||
|
||||
|
||||
|
||||
if (!conf->model_name.c_str()) {
|
||||
LOG(ERROR) << "no model file name\n";
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
/* create an environment */
|
||||
Ort::Env m_env(ORT_LOGGING_LEVEL_WARNING, "Onnx_environment");
|
||||
/* create session options */
|
||||
Ort::SessionOptions m_session_options;
|
||||
|
||||
/* Define number of threads */
|
||||
if (m_numberOfThreads != -1) {
|
||||
m_session_options.SetIntraOpNumThreads(m_numberOfThreads);
|
||||
if (m_verbose) {
|
||||
m_session_options.SetLogSeverityLevel(0);
|
||||
}
|
||||
}
|
||||
|
||||
m_session_options.DisableCpuMemArena();
|
||||
/* create a session from the ONNX model file */
|
||||
|
||||
Ort::Session session(m_env,conf->model_name.c_str(), m_session_options);
|
||||
if (session==nullptr)
|
||||
{ ORT_CXX_API_THROW("", OrtErrorCode::ORT_NO_MODEL );}
|
||||
|
||||
LOG(INFO) << "Loaded model " << conf->model_name << "\n";
|
||||
|
||||
Ort::TypeInfo inputTypeInfo = session.GetInputTypeInfo(0);
|
||||
auto tensorInfo = inputTypeInfo.GetTensorTypeAndShapeInfo();
|
||||
if (tensorInfo.GetElementType()== ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT)
|
||||
{
|
||||
m_inputFloating = true;
|
||||
LOG(INFO) << "Floating point Onnx Model\n";
|
||||
}
|
||||
m_session=std::move(session) ;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DisplaySettings()
|
||||
{
|
||||
LOG(INFO) << "input_floating " << m_inputFloating << "\n";
|
||||
LOG(INFO) << "input_mean " << m_inputMean << "\n";
|
||||
LOG(INFO) << "input_std " << m_inputStd << "\n";
|
||||
LOG(INFO) << "number_of_threads " << m_numberOfThreads << "\n";
|
||||
LOG(INFO) << "number_of_results " << m_numberOfResults << "\n";
|
||||
|
||||
}
|
||||
|
||||
void DisplayModelInformation()
|
||||
{
|
||||
|
||||
auto input_name = m_session.GetInputNameAllocated(0, m_allocator);
|
||||
const size_t num_input_nodes = m_session.GetInputCount();
|
||||
size_t num_output_nodes = m_session.GetOutputCount();
|
||||
|
||||
LOG(INFO) << "tensors size: " << num_input_nodes + num_output_nodes << "\n";
|
||||
LOG(INFO) << "inputs: " << num_input_nodes << "\n";
|
||||
LOG(INFO) << "input(0) name: " << input_name.get() << "\n";
|
||||
|
||||
/* Log information about input tensors */
|
||||
size_t numInputNodes = m_session.GetInputCount();
|
||||
for (size_t i = 0; i < numInputNodes; i++) {
|
||||
Ort::TypeInfo inputTypeInfo = m_session.GetInputTypeInfo(i);
|
||||
auto tensor_info = inputTypeInfo.GetTensorTypeAndShapeInfo();
|
||||
auto tensor_input_name = m_session.GetInputNameAllocated(i, m_allocator);
|
||||
if (tensor_input_name.get())
|
||||
{
|
||||
LOG(INFO) << i << ": " << tensor_input_name.get() << ", "
|
||||
<< tensor_info.GetElementCount() << ", " // the number of elements specified by the tensor shape (all dimensions multiplied by each other)
|
||||
<< tensor_info.GetElementType() << ", "
|
||||
<< tensor_info.GetDimensionsCount() << "\n" ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Log information about output tensors */
|
||||
size_t numOutputNodes = m_session.GetOutputCount();
|
||||
for (size_t i = 0; i < numOutputNodes; i++)
|
||||
{
|
||||
Ort::TypeInfo outputTypeInfo = m_session.GetOutputTypeInfo(i);
|
||||
auto tensor_info = outputTypeInfo.GetTensorTypeAndShapeInfo();
|
||||
auto tensor_output_name = m_session.GetOutputNameAllocated(i, m_allocator);
|
||||
if (tensor_output_name.get())
|
||||
{
|
||||
LOG(INFO) << i << ": " << tensor_output_name.get() << ", "
|
||||
<< tensor_info.GetElementCount()<< ", "
|
||||
<< tensor_info.GetElementType()<< ", "
|
||||
<< tensor_info.GetDimensionsCount() << "\n" ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool IsModelQuantized()
|
||||
{
|
||||
return !m_inputFloating;
|
||||
}
|
||||
|
||||
int GetInputWidth()
|
||||
{
|
||||
std::vector<int64_t> input_shape = m_session.GetInputTypeInfo(0).GetTensorTypeAndShapeInfo().GetShape();
|
||||
return input_shape[2];
|
||||
}
|
||||
|
||||
int GetInputHeight()
|
||||
{
|
||||
std::vector<int64_t> input_shape = m_session.GetInputTypeInfo(0).GetTensorTypeAndShapeInfo().GetShape();
|
||||
return input_shape[1];
|
||||
}
|
||||
|
||||
int GetInputChannels()
|
||||
{
|
||||
std::vector<int64_t> input_shape = m_session.GetInputTypeInfo(0).GetTensorTypeAndShapeInfo().GetShape();
|
||||
return input_shape[3];
|
||||
}
|
||||
|
||||
unsigned int GetNumberOfInputs()
|
||||
{
|
||||
return m_session.GetInputCount();
|
||||
}
|
||||
|
||||
unsigned int GetNumberOfOutputs()
|
||||
{
|
||||
return m_session.GetOutputCount();
|
||||
}
|
||||
|
||||
unsigned int GetOutputSize(int index)
|
||||
{
|
||||
Ort::TypeInfo type_info = m_session.GetOutputTypeInfo(index);
|
||||
// assume output dims to be something like (1, 1, ... ,size)
|
||||
return type_info.GetTensorTypeAndShapeInfo().GetShape()[type_info.GetTensorTypeAndShapeInfo().GetShape().size() - 1];
|
||||
}
|
||||
|
||||
|
||||
void RunInference(uint8_t* img, Frame_Results* results)
|
||||
{
|
||||
if (m_inputFloating)
|
||||
RunInference<float>(img, results);
|
||||
else
|
||||
RunInference<uint8_t>(img, results);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T Vector_Product(const std::vector<T>& vect)
|
||||
{
|
||||
return accumulate(vect.begin(), vect.end(), 1, std::multiplies<T>());
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
void RunInference(uint8_t* img, Frame_Results* results)
|
||||
{
|
||||
int input_height = GetInputHeight();
|
||||
int input_width = GetInputWidth();
|
||||
int input_channels = GetInputChannels();
|
||||
auto sizeInBytes = input_height * input_width * input_channels;
|
||||
auto input_name = m_session.GetInputNameAllocated(0, m_allocator);
|
||||
if (m_verbose) {
|
||||
LOG(INFO) << "input: " << input_name.get() << "\n";
|
||||
LOG(INFO) << "number of inputs: " << GetNumberOfInputs() << "\n";
|
||||
LOG(INFO) << "number of outputs: " << GetNumberOfOutputs() << "\n";
|
||||
}
|
||||
|
||||
/* Prepare input output tensors */
|
||||
std::vector<Ort::Value> inputTensors;
|
||||
std::vector<Ort::Value> outputTensors;
|
||||
|
||||
|
||||
std::vector< int64_t > inputDims=m_session.GetInputTypeInfo(0).GetTensorTypeAndShapeInfo().GetShape();
|
||||
size_t inputTensorSize =Vector_Product(inputDims); //sizeInBytes
|
||||
std::vector<int64_t> outputDims = m_session.GetOutputTypeInfo(0).GetTensorTypeAndShapeInfo().GetShape();
|
||||
size_t outputTensorSize = Vector_Product(outputDims);
|
||||
|
||||
|
||||
Ort::MemoryInfo memoryInfo = Ort::MemoryInfo::CreateCpu(OrtAllocatorType::OrtArenaAllocator, OrtMemType::OrtMemTypeDefault);
|
||||
|
||||
/* Prepare empty output tensor */
|
||||
std::vector<float> outputTensorValues(outputTensorSize);
|
||||
outputTensors.push_back(Ort::Value::CreateTensor(memoryInfo, outputTensorValues.data(), outputTensorSize, outputDims.data(), outputDims.size()));
|
||||
|
||||
/* Get input */
|
||||
float* in ;
|
||||
if (m_inputFloating) {
|
||||
for (int i = 0; i < sizeInBytes; i++){
|
||||
in[i] =(img[i] - m_inputMean) / m_inputStd;
|
||||
inputTensors.push_back(Ort::Value::CreateTensor(memoryInfo, &(in[i]) , inputTensorSize, inputDims.data(),inputDims.size()));}
|
||||
} else {
|
||||
for (int i = 0; i < sizeInBytes; i++)
|
||||
inputTensors.push_back(Ort::Value::CreateTensor(memoryInfo, &(img[i]), inputTensorSize, inputDims.data(),inputDims.size()));
|
||||
}
|
||||
|
||||
/* Get input names */
|
||||
size_t num_input_nodes = GetNumberOfInputs();
|
||||
input_name = m_session.GetInputNameAllocated(0, m_allocator);
|
||||
const char* inputNames[] = {input_name.get()};
|
||||
|
||||
/* Get Output names */
|
||||
size_t num_output_nodes = m_session.GetOutputCount();
|
||||
std::vector<std::string> output_names(num_output_nodes);
|
||||
for (size_t i = 0; i != num_output_nodes; ++i) {
|
||||
auto output_name = m_session.GetOutputNameAllocated(i, m_allocator);
|
||||
assert(output_name != nullptr);
|
||||
output_names[i] = output_name.get();
|
||||
}
|
||||
std::vector<const char*> outputNames(num_output_nodes);
|
||||
{
|
||||
for (size_t i = 0; i != num_output_nodes; ++i) {
|
||||
outputNames[i] = output_names[i].c_str();
|
||||
}
|
||||
}
|
||||
|
||||
/* Run Inference */
|
||||
Ort::RunOptions run_options;
|
||||
if (m_verbose) {
|
||||
run_options.SetRunLogSeverityLevel(0);
|
||||
}
|
||||
|
||||
struct timeval start_time, stop_time;
|
||||
gettimeofday(&start_time, nullptr);
|
||||
|
||||
std::cout << "Running inference ..." << std::endl;
|
||||
outputTensors = m_session.Run(run_options, inputNames, inputTensors.data(), num_input_nodes, outputNames.data(), num_output_nodes);
|
||||
|
||||
gettimeofday(&stop_time, nullptr);
|
||||
m_inferenceTime = (get_ms(stop_time) - get_ms(start_time));
|
||||
|
||||
/* Get results */
|
||||
float *locations = outputTensors[0].GetTensorMutableData<float>();
|
||||
float *classes = outputTensors[1].GetTensorMutableData<float>();
|
||||
float *scores = outputTensors[2].GetTensorMutableData<float>();
|
||||
|
||||
// get the output size by getting the size of the
|
||||
// output tensor 1 that represents the classes
|
||||
auto output_size = GetOutputSize(1);
|
||||
|
||||
// creation of an ObjDetect_Results struct to store values
|
||||
// of detected object of the frame
|
||||
ObjDetect_Results Obj_detected;
|
||||
|
||||
// the outputs are already sorted by descending order
|
||||
if (first_call){
|
||||
for (unsigned int i = 0; i < output_size; i++) {
|
||||
Obj_detected.classe =(int)classes[i];
|
||||
Obj_detected.score = scores[i];
|
||||
Obj_detected.location.y0 = locations[(i * 4) + 0];
|
||||
Obj_detected.location.x0 = locations[(i * 4) + 1];
|
||||
Obj_detected.location.y1 = locations[(i * 4) + 2];
|
||||
Obj_detected.location.x1 = locations[(i * 4) + 3];
|
||||
results->vect_ObjDetect_Results.push_back(Obj_detected);
|
||||
}
|
||||
results->inference_time = m_inferenceTime;
|
||||
} else {
|
||||
for (unsigned int i = 0; i < output_size; i++) {
|
||||
results->vect_ObjDetect_Results.erase(results->vect_ObjDetect_Results.begin()+i);
|
||||
Obj_detected.classe =(int)classes[i];
|
||||
Obj_detected.score = scores[i];
|
||||
Obj_detected.location.y0 = locations[(i * 4) + 0];
|
||||
Obj_detected.location.x0 = locations[(i * 4) + 1];
|
||||
Obj_detected.location.y1 = locations[(i * 4) + 2];
|
||||
Obj_detected.location.x1 = locations[(i * 4) + 3];
|
||||
results->vect_ObjDetect_Results.insert(results->vect_ObjDetect_Results.begin()+i,Obj_detected);
|
||||
}
|
||||
results->inference_time = m_inferenceTime;
|
||||
}
|
||||
first_call = false;
|
||||
}
|
||||
|
||||
// Takes a file name, and loads a list of labels from it, one per line, and
|
||||
// returns a vector of the strings. It pads with empty strings so the length
|
||||
// of the result is a multiple of 16, because our model expects that.
|
||||
bool ReadLabelsFile(const std::string& file_name,
|
||||
std::vector<std::string>* result,
|
||||
size_t* found_label_count)
|
||||
{
|
||||
std::ifstream file(file_name);
|
||||
if (!file) {
|
||||
LOG(FATAL) << "Labels file " << file_name << " not found\n";
|
||||
return 0;
|
||||
}
|
||||
result->clear();
|
||||
std::string line;
|
||||
while (std::getline(file, line)) {
|
||||
result->push_back(line);
|
||||
}
|
||||
*found_label_count = result->size();
|
||||
const int padding = 16;
|
||||
while (result->size() % padding) {
|
||||
result->emplace_back();
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace wrapper_onnx
|
||||
|
||||
#endif // WRAPPER_ONNX_HPP_
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
Application:
|
||||
Name: Object Detection
|
||||
Description: YoloV4 tiny
|
||||
Icon: ../demo-ai/resources/tfl_python.png
|
||||
Board:
|
||||
List: all
|
||||
Type: script
|
||||
Script:
|
||||
Exist:
|
||||
File: /usr/local/demo-ai/resources/check_camera_preview.sh
|
||||
Msg_false: Camera is not connected
|
||||
Start: ../demo-ai/object-detection/tflite/launch_python_object_detection.sh
|
||||
Action:
|
||||
button_release_event: script_management
|
||||
button_press_event: highlight_eventBox
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
Application:
|
||||
Name: Object Detection
|
||||
Description: COCO SSD v1
|
||||
Icon: ../demo-ai/resources/tfl_python.png
|
||||
Board:
|
||||
List: all
|
||||
Type: script
|
||||
Script:
|
||||
Exist:
|
||||
File: /usr/local/demo-ai/resources/check_camera_preview.sh
|
||||
Msg_false: Camera is not connected
|
||||
Start: ../demo-ai/object-detection/tflite/launch_python_object_detection.sh
|
||||
Action:
|
||||
button_release_event: script_management
|
||||
button_press_event: highlight_eventBox
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
Application:
|
||||
Name: Object Detection
|
||||
Description: COCO SSD v1
|
||||
Icon: ../demo-ai/resources/tfl_cpp.png
|
||||
Board:
|
||||
List: all
|
||||
Type: script
|
||||
Script:
|
||||
Exist:
|
||||
File: /usr/local/demo-ai/resources/check_camera_preview.sh
|
||||
Msg_false: Camera is not connected
|
||||
Start: ../demo-ai/object-detection/tflite/launch_bin_object_detection.sh
|
||||
Action:
|
||||
button_release_event: script_management
|
||||
button_press_event: highlight_eventBox
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
Application:
|
||||
Name: Object Detection
|
||||
Description: COCO SSD v1
|
||||
Icon: ../demo-ai/resources/coral_python.png
|
||||
Board:
|
||||
List: all
|
||||
Type: script
|
||||
Script:
|
||||
Exist:
|
||||
File: /usr/local/demo-ai/resources/check_camera_preview.sh
|
||||
Msg_false: Camera is not connected
|
||||
Start: ../demo-ai/object-detection/coral/launch_coral_python_object_detection.sh
|
||||
Action:
|
||||
button_release_event: script_management
|
||||
button_press_event: highlight_eventBox
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
Application:
|
||||
Name: Object Detection
|
||||
Description: COCO SSD v1
|
||||
Icon: ../demo-ai/resources/coral_cpp.png
|
||||
Board:
|
||||
List: all
|
||||
Type: script
|
||||
Script:
|
||||
Exist:
|
||||
File: /usr/local/demo-ai/resources/check_camera_preview.sh
|
||||
Msg_false: Camera is not connected
|
||||
Start: ../demo-ai/object-detection/coral/launch_coral_bin_object_detection.sh
|
||||
Action:
|
||||
button_release_event: script_management
|
||||
button_press_event: highlight_eventBox
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
OPENCV_PKGCONFIG?="opencv4"
|
||||
SYSROOT?=""
|
||||
EDGETPU?=""
|
||||
ARCHITECTURE?=""
|
||||
TARGET_BIN = tflite_object_detection
|
||||
|
||||
CXXFLAGS += -Wall $(shell pkg-config --cflags gtk+-3.0 $(OPENCV_PKGCONFIG) gstreamer-plugins-base-1.0 gstreamer-wayland-1.0)
|
||||
CXXFLAGS += -std=c++17
|
||||
CXXFLAGS += -I$(SYSROOT)/usr/include/tensorflow/lite/flatbuffers/include
|
||||
CXXFLAGS += -I$(SYSROOT)/usr/include/tensorflow/lite/abseil-cpp
|
||||
CXXFLAGS += -I$(SYSROOT)/usr/include/rapidjson
|
||||
|
||||
LDFLAGS = $(shell pkg-config --libs gtk+-3.0 gstreamer-plugins-base-1.0 gstreamer-wayland-1.0)
|
||||
LDFLAGS += -lpthread -ldl -lopencv_core -lopencv_imgproc -lopencv_imgcodecs -ltensorflow-lite
|
||||
ifneq (,$(findstring stm32mp2_npu,$(ARCHITECTURE)))
|
||||
CXXFLAGS += -DVSI_OP
|
||||
LDFLAGS += -lvx_custom_op
|
||||
endif
|
||||
|
||||
ifneq (,$(findstring TRUE,$(EDGETPU)))
|
||||
CXXFLAGS += -DEDGETPU
|
||||
LDFLAGS += -ledgetpu
|
||||
endif
|
||||
|
||||
SRCS = tflite_object_detection.cc
|
||||
OBJS = $(SRCS:.cc=.o)
|
||||
|
||||
all: $(TARGET_BIN)
|
||||
|
||||
$(TARGET_BIN): $(OBJS)
|
||||
$(CXX) -o $@ $^ $(LDFLAGS)
|
||||
|
||||
$(OBJS): $(SRCS)
|
||||
$(CXX) $(CXXFLAGS) -c $^
|
||||
|
||||
clean:
|
||||
rm -rf $(OBJS) $(TARGET_BIN)
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
#!/bin/sh
|
||||
weston_user=$(ps aux | grep '/usr/bin/weston '|grep -v 'grep'|awk '{print $1}')
|
||||
|
||||
source /usr/local/demo-ai/resources/config_board.sh
|
||||
cmd="/usr/local/demo-ai/object-detection/tflite/tflite_object_detection -m /usr/local/demo-ai/object-detection/models/coco_ssd_mobilenet/coco_ssd_mobilenet.tflite -l /usr/local/demo-ai/object-detection/models/coco_ssd_mobilenet/labels_coco_ssd_mobilenet.txt --framerate $DFPS --frame_width $DWIDTH --frame_height $DHEIGHT $COMPUTE_ENGINE"
|
||||
|
||||
if [ "$weston_user" != "root" ]; then
|
||||
echo "user : "$weston_user
|
||||
script -qc "su -l $weston_user -c '$cmd'"
|
||||
else
|
||||
$cmd
|
||||
fi
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
#!/bin/sh
|
||||
weston_user=$(ps aux | grep '/usr/bin/weston '|grep -v 'grep'|awk '{print $1}')
|
||||
|
||||
source /usr/local/demo-ai/resources/config_board.sh
|
||||
cmd="/usr/local/demo-ai/object-detection/tflite/tflite_object_detection -m /usr/local/demo-ai/object-detection/models/coco_ssd_mobilenet/coco_ssd_mobilenet.tflite -l /usr/local/demo-ai/object-detection/models/coco_ssd_mobilenet/labels_coco_ssd_mobilenet.txt -i /usr/local/demo-ai/object-detection/models/coco_ssd_mobilenet/testdata/ $COMPUTE_ENGINE"
|
||||
|
||||
if [ "$weston_user" != "root" ]; then
|
||||
echo "user : "$weston_user
|
||||
script -qc "su -l $weston_user -c '$cmd'"
|
||||
else
|
||||
$cmd
|
||||
fi
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
#!/bin/sh
|
||||
weston_user=$(ps aux | grep '/usr/bin/weston '|grep -v 'grep'|awk '{print $1}')
|
||||
|
||||
source /usr/local/demo-ai/resources/config_board.sh
|
||||
cmd="/usr/local/demo-ai/object-detection/coral/coral_object_detection -m /usr/local/demo-ai/object-detection/models/coco_ssd_mobilenet/coco_ssd_mobilenet_edgetpu.tflite -l /usr/local/demo-ai/object-detection/models/coco_ssd_mobilenet/labels_coco_ssd_mobilenet.txt --framerate $DFPS --frame_width $DWIDTH --frame_height $DHEIGHT --edgetpu"
|
||||
|
||||
if [ "$weston_user" != "root" ]; then
|
||||
echo "user : "$weston_user
|
||||
script -qc "su -l $weston_user -c '$cmd'"
|
||||
else
|
||||
$cmd
|
||||
fi
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
#!/bin/sh
|
||||
weston_user=$(ps aux | grep '/usr/bin/weston '|grep -v 'grep'|awk '{print $1}')
|
||||
|
||||
cmd="/usr/local/demo-ai/object-detection/coral/coral_object_detection -m /usr/local/demo-ai/object-detection/models/coco_ssd_mobilenet/coco_ssd_mobilenet_edgetpu.tflite -l /usr/local/demo-ai/object-detection/models/coco_ssd_mobilenet/labels_coco_ssd_mobilenet.txt -i /usr/local/demo-ai/object-detection/models/coco_ssd_mobilenet/testdata/ --edgetpu"
|
||||
if [ "$weston_user" != "root" ]; then
|
||||
echo "user : "$weston_user
|
||||
script -qc "su -l $weston_user -c '$cmd'"
|
||||
else
|
||||
$cmd
|
||||
fi
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
#!/bin/sh
|
||||
weston_user=$(ps aux | grep '/usr/bin/weston '|grep -v 'grep'|awk '{print $1}')
|
||||
|
||||
source /usr/local/demo-ai/resources/config_board.sh
|
||||
cmd="python3 /usr/local/demo-ai/object-detection/coral/coral_object_detection.py -m /usr/local/demo-ai/object-detection/models/coco_ssd_mobilenet/coco_ssd_mobilenet_edgetpu.tflite -l /usr/local/demo-ai/object-detection/models/coco_ssd_mobilenet/labels_coco_ssd_mobilenet.txt --framerate $DFPS --frame_width $DWIDTH --frame_height $DHEIGHT --edgetpu"
|
||||
|
||||
if [ "$weston_user" != "root" ]; then
|
||||
echo "user : "$weston_user
|
||||
script -qc "su -l $weston_user -c '$cmd'"
|
||||
else
|
||||
$cmd
|
||||
fi
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
#!/bin/sh
|
||||
weston_user=$(ps aux | grep '/usr/bin/weston '|grep -v 'grep'|awk '{print $1}')
|
||||
|
||||
cmd="python3 /usr/local/demo-ai/object-detection/coral/coral_object_detection.py -m /usr/local/demo-ai/object-detection/models/coco_ssd_mobilenet/coco_ssd_mobilenet_edgetpu.tflite -l /usr/local/demo-ai/object-detection/models/coco_ssd_mobilenet/labels_coco_ssd_mobilenet.txt -i /usr/local/demo-ai/object-detection/models/coco_ssd_mobilenet/testdata/ --edgetpu "
|
||||
if [ "$weston_user" != "root" ]; then
|
||||
echo "user : "$weston_user
|
||||
script -qc "su -l $weston_user -c '$cmd'"
|
||||
else
|
||||
$cmd
|
||||
fi
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
#!/bin/sh
|
||||
weston_user=$(ps aux | grep '/usr/bin/weston '|grep -v 'grep'|awk '{print $1}')
|
||||
|
||||
source /usr/local/demo-ai/resources/config_board.sh
|
||||
cmd="python3 /usr/local/demo-ai/object-detection/tflite/tflite_object_detection.py -m /usr/local/demo-ai/object-detection/models/coco_ssd_mobilenet/coco_ssd_mobilenet.tflite -l /usr/local/demo-ai/object-detection/models/coco_ssd_mobilenet/labels_coco_ssd_mobilenet.txt --framerate $DFPS --frame_width $DWIDTH --frame_height $DHEIGHT $COMPUTE_ENGINE"
|
||||
|
||||
if [ "$weston_user" != "root" ]; then
|
||||
echo "user : "$weston_user
|
||||
script -qc "su -l $weston_user -c '$cmd'"
|
||||
else
|
||||
$cmd
|
||||
fi
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
#!/bin/sh
|
||||
weston_user=$(ps aux | grep '/usr/bin/weston '|grep -v 'grep'|awk '{print $1}')
|
||||
|
||||
source /usr/local/demo-ai/resources/config_board.sh
|
||||
cmd="python3 /usr/local/demo-ai/object-detection/tflite/tflite_object_detection.py -m /usr/local/demo-ai/object-detection/models/yolov4-tiny/yolov4_tiny_416_quant.tflite -l /usr/local/demo-ai/object-detection/models/yolov4-tiny/labels_yolov4_tiny.txt --framerate $DFPS --frame_width $DWIDTH --frame_height $DHEIGHT $COMPUTE_ENGINE"
|
||||
|
||||
if [ "$weston_user" != "root" ]; then
|
||||
echo "user : "$weston_user
|
||||
script -qc "su -l $weston_user -c '$cmd'"
|
||||
else
|
||||
$cmd
|
||||
fi
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
#!/bin/sh
|
||||
weston_user=$(ps aux | grep '/usr/bin/weston '|grep -v 'grep'|awk '{print $1}')
|
||||
|
||||
source /usr/local/demo-ai/resources/config_board.sh
|
||||
cmd="python3 /usr/local/demo-ai/object-detection/tflite/tflite_object_detection.py -m /usr/local/demo-ai/object-detection/models/coco_ssd_mobilenet/coco_ssd_mobilenet.tflite -l /usr/local/demo-ai/object-detection/models/coco_ssd_mobilenet/labels_coco_ssd_mobilenet.txt -i /usr/local/demo-ai/object-detection/models/coco_ssd_mobilenet/testdata/ $COMPUTE_ENGINE"
|
||||
|
||||
if [ "$weston_user" != "root" ]; then
|
||||
echo "user : "$weston_user
|
||||
script -qc "su -l $weston_user -c '$cmd'"
|
||||
else
|
||||
$cmd
|
||||
fi
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
#!/bin/sh
|
||||
weston_user=$(ps aux | grep '/usr/bin/weston '|grep -v 'grep'|awk '{print $1}')
|
||||
|
||||
source /usr/local/demo-ai/resources/config_board.sh
|
||||
cmd="python3 /usr/local/demo-ai/object-detection/tflite/tflite_object_detection.py -m /usr/local/demo-ai/object-detection/models/yolov4-tiny/yolov4_tiny_416_quant.tflite -l /usr/local/demo-ai/object-detection/models/yolov4-tiny/labels_yolov4_tiny.txt -i /usr/local/demo-ai/object-detection/models/yolov4-tiny/testdata/ $COMPUTE_ENGINE"
|
||||
|
||||
if [ "$weston_user" != "root" ]; then
|
||||
echo "user : "$weston_user
|
||||
script -qc "su -l $weston_user -c '$cmd'"
|
||||
else
|
||||
$cmd
|
||||
fi
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue