Skip to content

Commit

Permalink
release v1.0.0
Browse files Browse the repository at this point in the history
Compatible with:
openstlinux-4.19-thud-mp1-19-02-20.

Contains:
X-LINUX-AI-CV Expansion Package v1.0.0

Signed-off-by: Vincent Abriou <[email protected]>
  • Loading branch information
vinceab committed Aug 1, 2019
1 parent b30c21d commit 7e2fdbd
Show file tree
Hide file tree
Showing 35 changed files with 2,379 additions and 0 deletions.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,21 @@
# meta-st-stm32mpu-ai
OpenEmbedded meta layer to install AI frameworks and tools for the STM32MP1.

Available images:
* st-image-ai-cv for Computer Vision

## Compatibility
Compatible with the following OpenSTLinux Distribution release:
* openstlinux-4.19-thud-mp1-19-02-20

## Available frameworks and tools within the meta-layer
[X-LINUX-AI-CV v1.0.0 expansion package](https://wiki.st.com/stm32mpu/wiki/X-LINUX-AI-CV_OpenSTLinux_expansion_package):
* TensorFlow Lite 2.0.0-beta1
* OpenCV 3.4.x
* Python 3.5.x (enabling Pillow module)
* Python Application examples
* Image classification example based on MobileNet v1 model
* Object detection example based on COCO SSD MobileNet v1 model

## Further information (how to install, how to use, ...)
<https://wiki.st.com/stm32mpu/wiki/STM32MP1_artificial_intelligence_expansion_packages>
19 changes: 19 additions & 0 deletions conf/layer.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# We have a conf and classes directory, add to BBPATH
BBPATH .= ":${LAYERDIR}"

# We have a recipes-* directories, add to BBFILES
BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \
${LAYERDIR}/recipes-*/*/*.bbappend"

BBFILE_COLLECTIONS += "stm32mpu-ai"
BBFILE_PATTERN_stm32mpu-ai := "^${LAYERDIR}/"
BBFILE_PRIORITY_stm32mpu-ai = "9"

# This should only be incremented on significant changes that will
# cause compatibility issues with other layers
LAYERVERSION_stm32mpu-ai = "1"
LAYERSERIES_COMPAT_stm32mpu-ai = "thud"

LAYERDEPENDS_stm32mpu-ai = "stm-st-stm32mp"
LAYERDEPENDS_stm32mpu-ai += "st-openstlinux"
LAYERDEPENDS_stm32mpu-ai += "clang-layer"
2 changes: 2 additions & 0 deletions recipes-devtools/clang/libcxx_git.bbappend
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#Avoid meta-clang to provide libunwind
PACKAGECONFIG = ""
3 changes: 3 additions & 0 deletions recipes-devtools/python/python3-native_3.5.6.bbappend
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#Do not apply the following patch that will cause tensorflow-lite pip package
#build to fails
SRC_URI_remove += " file://unixccompiler.patch "
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
From 52879439f2976662140b76951f43f16e1d5ef08e Mon Sep 17 00:00:00 2001
From: Hongxu Jia <[email protected]>
Date: Mon, 18 Mar 2019 23:23:55 -0400
Subject: [PATCH] explicitly set compile options

OE does not support to install egg package, so
explicitly set build_ext options for oe-core's
`setup.py install'

Upstream-Status: Inappropriate [oe specific]

Signed-off-by: Hongxu Jia <[email protected]>
---
setup.cfg | 12 ++++++++++++
1 file changed, 12 insertions(+)

diff --git a/setup.cfg b/setup.cfg
index 95900ff..27da313 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -9,3 +9,15 @@ addopts = -vx Tests

[flake8]
max-line-length = 88
+
+[build_ext]
+disable-platform-guessing = 1
+enable-zlib = 1
+enable-jpeg = 1
+enable-tiff = 1
+enable-freetype = 1
+enable-lcms = 1
+enable-jpeg2000 = 1
+disable-webp = 1
+disable-webpmux = 1
+disable-imagequant = 1
--
2.8.1

Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
From a78411402c824668283beb94db4bf7e206a4cf60 Mon Sep 17 00:00:00 2001
From: Hongxu Jia <[email protected]>
Date: Thu, 14 Mar 2019 03:48:10 -0400
Subject: [PATCH] support cross compiling

Upstream-Status: Inappropriate [oe specific]

Signed-off-by: Hongxu Jia <[email protected]>
---
setup.py | 13 +++----------
1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/setup.py b/setup.py
index 79f912b..37e5827 100755
--- a/setup.py
+++ b/setup.py
@@ -50,7 +50,7 @@ _LIB_IMAGING = (
"ZipEncode", "TiffDecode", "Jpeg2KDecode", "Jpeg2KEncode", "BoxBlur",
"QuantPngQuant", "codec_fd")

-DEBUG = False
+DEBUG = True


class DependencyException(Exception):
@@ -345,21 +345,16 @@ class pil_build_ext(build_ext):
_add_directory(library_dirs, match.group(1))

# include, rpath, if set as environment variables:
- for k in ('C_INCLUDE_PATH', 'CPATH', 'INCLUDE'):
+ for k in ('C_INCLUDE_PATH', 'CPATH', 'INCLUDE', 'STAGING_INCDIR'):
if k in os.environ:
for d in os.environ[k].split(os.path.pathsep):
_add_directory(include_dirs, d)

- for k in ('LD_RUN_PATH', 'LIBRARY_PATH', 'LIB'):
+ for k in ('LD_RUN_PATH', 'LIBRARY_PATH', 'LIB', 'STAGING_LIBDIR'):
if k in os.environ:
for d in os.environ[k].split(os.path.pathsep):
_add_directory(library_dirs, d)

- prefix = sysconfig.get_config_var("prefix")
- if prefix:
- _add_directory(library_dirs, os.path.join(prefix, "lib"))
- _add_directory(include_dirs, os.path.join(prefix, "include"))
-
#
# add platform directories

@@ -413,8 +408,6 @@ class pil_build_ext(build_ext):
elif sys.platform.startswith("linux") or \
sys.platform.startswith("gnu") or \
sys.platform.startswith("freebsd"):
- for dirname in _find_library_dirs_ldconfig():
- _add_directory(library_dirs, dirname)
if sys.platform.startswith("linux") and \
os.environ.get('ANDROID_ROOT', None):
# termux support for android.
--
2.8.1

28 changes: 28 additions & 0 deletions recipes-devtools/python/python3-pillow_5.4.1.bb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
SUMMARY = "Python Imaging Library (Fork). Pillow is the friendly PIL fork by Alex \
Clark and Contributors. PIL is the Python Imaging Library by Fredrik Lundh and \
Contributors."
HOMEPAGE = "https://pillow.readthedocs.io"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://LICENSE;md5=c6379001ecb47e2a0420c40177fc1125"

SRC_URI = "git://github.com/python-pillow/Pillow.git;branch=5.4.x \
file://0001-support-cross-compiling.patch \
file://0001-explicitly-set-compile-options.patch \
"
SRCREV ?= "f38f01bbe3a0a9f49ce592c86ff20c01c9655133"


inherit setuptools3

DEPENDS += " \
zlib \
jpeg \
tiff \
freetype \
lcms \
openjpeg \
"

S = "${WORKDIR}/git"

BBCLASSEXTEND = "native"
16 changes: 16 additions & 0 deletions recipes-devtools/python/python3-wheel_0.32.3.bb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
SUMMARY = "The official binary distribution format for Python "
HOMEPAGE = "https://github.com/pypa/wheel"
SECTION = "devel/python"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=9d66b41bc2a080e7174acc5dffecd752"

SRC_URI = "git://github.com/pypa/wheel.git"
SRCREV ?= "11584b78a56b4eedba4eedc55c9dac8aa2dd7070"


inherit setuptools3

S = "${WORKDIR}/git"

BBCLASSEXTEND = "native"

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
From 6dfb0a848ee89802b7c29be3307316385bc62466 Mon Sep 17 00:00:00 2001
From: Vincent Abriou <[email protected]>
Date: Mon, 8 Apr 2019 11:51:58 +0200
Subject: [PATCH 1/4] TFLite: allow BUILD_WITH_NNAPI Makefile variable to
disable NNAPI support

In cross compiling environment, calling the Makefile with
BUILD_WITH_NNAPI=flase will disable the support of NNAPI.
This is requiered to support other Linux target than Rpi.

Signed-off-by: Vincent Abriou <[email protected]>
---
tensorflow/lite/tools/make/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tensorflow/lite/tools/make/Makefile b/tensorflow/lite/tools/make/Makefile
index 8428e0d..4f7027c 100644
--- a/tensorflow/lite/tools/make/Makefile
+++ b/tensorflow/lite/tools/make/Makefile
@@ -124,7 +124,7 @@ else
CORE_CC_EXCLUDE_SRCS += tensorflow/lite/mmap_allocation_disabled.cc
endif

-BUILD_WITH_NNAPI=true
+BUILD_WITH_NNAPI:=true
ifeq ($(BUILD_TYPE),micro)
BUILD_WITH_NNAPI=false
endif
--
2.7.4

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
From 0578a5718f80076c588fa48c351e0452acbb403a Mon Sep 17 00:00:00 2001
From: Vincent Abriou <[email protected]>
Date: Mon, 8 Apr 2019 12:05:21 +0200
Subject: [PATCH 2/4] TFLite pip package: use local BUILD_ROOT directory

To support cross compiling environment local BUILD_ROOT directory is
needed.

Signed-off-by: Vincent Abriou <[email protected]>
---
tensorflow/lite/tools/pip_package/build_pip_package.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tensorflow/lite/tools/pip_package/build_pip_package.sh b/tensorflow/lite/tools/pip_package/build_pip_package.sh
index 2887ce8..ef9ea54 100644
--- a/tensorflow/lite/tools/pip_package/build_pip_package.sh
+++ b/tensorflow/lite/tools/pip_package/build_pip_package.sh
@@ -24,7 +24,7 @@ export TENSORFLOW_VERSION=`grep "_VERSION = " $TENSORFLOW_SRC_ROOT/tensorflow/to


# Build a pip build tree.
-BUILD_ROOT=/tmp/tflite_pip
+BUILD_ROOT=$MY_DIRECTORY/gen/tflite_pip
rm -rf $BUILD_ROOT
mkdir -p $BUILD_ROOT/tflite_runtime/lite
mkdir -p $BUILD_ROOT/tflite_runtime/lite/python
--
2.7.4

Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
From c3d1cad1bb78190a7fbca49d33dfa87a2ba1ca4b Mon Sep 17 00:00:00 2001
From: Vincent Abriou <[email protected]>
Date: Mon, 8 Apr 2019 12:01:16 +0200
Subject: [PATCH 3/4] TFLite pip package: support cross compiling environment

Signed-off-by: Vincent Abriou <[email protected]>
---
.../lite/tools/pip_package/build_pip_package.sh | 6 +++++-
tensorflow/lite/tools/pip_package/setup.py | 20 ++++++++++++++++++++
2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/tensorflow/lite/tools/pip_package/build_pip_package.sh b/tensorflow/lite/tools/pip_package/build_pip_package.sh
index ef9ea54..5dc9ebf 100644
--- a/tensorflow/lite/tools/pip_package/build_pip_package.sh
+++ b/tensorflow/lite/tools/pip_package/build_pip_package.sh
@@ -51,4 +51,8 @@ cp $TFLITE_ROOT/tools/pip_package/MANIFEST.in $BUILD_ROOT

# Build the Pip
cd $BUILD_ROOT
-python setup.py bdist_wheel
+if [ -n "${TENSORFLOW_TARGET}" ] && [ -n "${TENSORFLOW_TARGET_ARCH}" ]; then
+ python3 setup.py bdist_wheel --plat-name=${TENSORFLOW_TARGET}-${TENSORFLOW_TARGET_ARCH}
+else
+ python3 setup.py bdist_wheel
+fi
diff --git a/tensorflow/lite/tools/pip_package/setup.py b/tensorflow/lite/tools/pip_package/setup.py
index c5141c1..38d3fb3 100644
--- a/tensorflow/lite/tools/pip_package/setup.py
+++ b/tensorflow/lite/tools/pip_package/setup.py
@@ -50,6 +50,26 @@ if TARGET == 'rpi':
os.environ['CC'] = 'arm-linux-gnueabihf-g++'
MAKE_CROSS_OPTIONS = ['TARGET=%s' % TARGET] if TARGET else []

+TARGET_ARCH = (
+ os.environ['TENSORFLOW_TARGET_ARCH'] if 'TENSORFLOW_TARGET_ARCH' in os.environ
+ else None)
+MAKE_CROSS_OPTIONS += ['TARGET_ARCH=%s' % TARGET_ARCH] if TARGET_ARCH else []
+
+CC_PREFIX = (
+ os.environ['TENSORFLOW_CC_PREFIX'] if 'TENSORFLOW_CC_PREFIX' in os.environ
+ else None)
+MAKE_CROSS_OPTIONS += ['CC_PREFIX=%s' % CC_PREFIX] if CC_PREFIX else []
+
+EXTRA_CXXFLAGS = (
+ os.environ['TENSORFLOW_EXTRA_CXXFLAGS'] if 'TENSORFLOW_EXTRA_CXXFLAGS' in os.environ
+ else None)
+MAKE_CROSS_OPTIONS += ['EXTRA_CXXFLAGS=%s' % EXTRA_CXXFLAGS] if EXTRA_CXXFLAGS else []
+
+BUILD_WITH_NNAPI = (
+ os.environ['TENSORFLOW_BUILD_WITH_NNAPI'] if 'TENSORFLOW_BUILD_WITH_NNAPI' in os.environ
+ else 'true')
+MAKE_CROSS_OPTIONS += ['BUILD_WITH_NNAPI=%s' % BUILD_WITH_NNAPI] if BUILD_WITH_NNAPI else []
+
RELATIVE_MAKE_DIR = os.path.join('tensorflow', 'lite', 'tools', 'make')
MAKE_DIR = os.path.join(TENSORFLOW_DIR, RELATIVE_MAKE_DIR)
DOWNLOADS_DIR = os.path.join(MAKE_DIR, 'downloads')
--
2.7.4

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
From b048fc3161f5949220b19faf49437c715b64521a Mon Sep 17 00:00:00 2001
From: Vincent Abriou <[email protected]>
Date: Mon, 8 Apr 2019 12:08:16 +0200
Subject: [PATCH 4/4] TFLite pip package: fix python execution issue

No Module named 'interpreter'
'interpreter' does not refer to any module but
'tflite_runtime.lite.interpreter' does.

Signed-off-by: Vincent Abriou <[email protected]>
---
tensorflow/lite/tools/pip_package/build_pip_package.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tensorflow/lite/tools/pip_package/build_pip_package.sh b/tensorflow/lite/tools/pip_package/build_pip_package.sh
index 5dc9ebf..e720a7a 100644
--- a/tensorflow/lite/tools/pip_package/build_pip_package.sh
+++ b/tensorflow/lite/tools/pip_package/build_pip_package.sh
@@ -35,7 +35,7 @@ import tflite_runtime.lite.interpreter
EOF

cat > $BUILD_ROOT/tflite_runtime/lite/__init__.py <<EOF;
-from interpreter import Interpreter as Interpreter
+from tflite_runtime.lite.interpreter import Interpreter as Interpreter
EOF

cat > $BUILD_ROOT/tflite_runtime/lite/python/__init__.py <<EOF;
--
2.7.4

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
From 0053e7c332a7439a0958e3740fdb0e407826eba4 Mon Sep 17 00:00:00 2001
From: Vincent Abriou <[email protected]>
Date: Wed, 10 Apr 2019 16:07:18 +0200
Subject: [PATCH 1/1] TFLite pip package: fix _interpreter_wrapper.so undefined
symbol

Build dependencies of interpreter_wrapper such as:
numpy.cc
python_error_reporter.cc
python_utils.cc

Signed-off-by: Vincent Abriou <[email protected]>
---
tensorflow/lite/tools/pip_package/setup.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tensorflow/lite/tools/pip_package/setup.py b/tensorflow/lite/tools/pip_package/setup.py
index 38d3fb3..cc060c4 100644
--- a/tensorflow/lite/tools/pip_package/setup.py
+++ b/tensorflow/lite/tools/pip_package/setup.py
@@ -143,7 +143,10 @@ ext = Extension(
name='%s._interpreter_wrapper' % PACKAGE,
language='c++',
sources=['interpreter_wrapper/interpreter_wrapper.i',
- 'interpreter_wrapper/interpreter_wrapper.cc'],
+ 'interpreter_wrapper/interpreter_wrapper.cc',
+ 'interpreter_wrapper/numpy.cc',
+ 'interpreter_wrapper/python_error_reporter.cc',
+ 'interpreter_wrapper/python_utils.cc'],
swig_opts=['-c++',
'-I%s' % TENSORFLOW_DIR,
'-module', 'interpreter_wrapper',
--
2.7.4

Loading

0 comments on commit 7e2fdbd

Please sign in to comment.