From bf0c5819594775ec7b1f49b09c753f52ba5f5e6d Mon Sep 17 00:00:00 2001 From: Markus Beissinger Date: Wed, 23 Feb 2022 01:28:01 -0800 Subject: [PATCH] Update requirements to latest versions, change tflite-runtime to pypi install, add tags to setup.py (#33) --- .gitignore | 1 + README.md | 7 ++- RELEASE.md | 8 ++++ scripts/lobe-rpi-install.sh | 6 +-- setup.py | 91 ++++++++++++------------------------- 5 files changed, 44 insertions(+), 69 deletions(-) diff --git a/.gitignore b/.gitignore index 4c268f1..9cc2e73 100644 --- a/.gitignore +++ b/.gitignore @@ -116,6 +116,7 @@ venv.bak/ .v37 .v38 .v39 +.v310 # Spyder project settings .spyderproject diff --git a/README.md b/README.md index 4a41f81..1faf48b 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Lobe Python API Code to run exported Lobe models in Python using the TensorFlow, TensorFlow Lite, or ONNX options. -Works with Python 3.6, 3.7, 3.8, and 3.9 untested for other versions. +Works with Python 3.7, 3.8, 3.9, and 3.10 untested for other versions. [Note: 3.10 only works with the TensorFlow backend] ## Install ### Backend options with pip @@ -13,9 +13,8 @@ pip install lobe[all] # For TensorFlow only pip install lobe[tf] -# For TensorFlow Lite only -- this requires two steps for the runtime and for lobe (note for Raspberry Pi see our setup script in scripts/lobe-rpi-install.sh) -pip install --index-url https://google-coral.github.io/py-repo/ tflite_runtime -pip install lobe +# For TensorFlow Lite only (note for Raspberry Pi see our setup script in scripts/lobe-rpi-install.sh) +pip install lobe[tflite] # For ONNX only pip install lobe[onnx] diff --git a/RELEASE.md b/RELEASE.md index dbdd1bf..2ba6436 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -1,3 +1,11 @@ +# Release 0.6.2 +___ +## Bug Fixes and Other Improvements +* Add support for Python 3.10, drop support for Python 3.6. +* Bump requirements to latest versions. +* Update Raspberry Pi and setup install to latest tensorflow-lite guidance. + + # Release 0.6.1 ___ ## Bug Fixes and Other Improvements diff --git a/scripts/lobe-rpi-install.sh b/scripts/lobe-rpi-install.sh index c63b80f..6d9e36c 100644 --- a/scripts/lobe-rpi-install.sh +++ b/scripts/lobe-rpi-install.sh @@ -13,7 +13,5 @@ sudo apt install -y \ libjpeg62-turbo sudo apt-get install -y git sudo pip3 install setuptools -# Install TensorFlow Lite Runtime -sudo apt install -y python3-tflite-runtime -# Install lobe-python which can use the tflite backend -sudo pip3 install lobe \ No newline at end of file +# Install lobe-python to use the tflite backend +sudo pip3 install lobe[tflite] \ No newline at end of file diff --git a/setup.py b/setup.py index 2e50257..e721c7e 100644 --- a/setup.py +++ b/setup.py @@ -1,86 +1,55 @@ from setuptools import setup, find_packages -import sys import pathlib -import platform parent = pathlib.Path(__file__).parent # get the readme for use in our long description readme = (parent / "README.md").read_text() -python_version = platform.python_version().rsplit('.', maxsplit=1)[0] - -mac_v, _, _ = platform.mac_ver() -if mac_v != '': - mac_v_split = mac_v.split('.') - mac_major_version = mac_v_split[0] - mac_minor_version = mac_v_split[1] - mac_version = '.'.join([mac_major_version, mac_minor_version]) -else: - mac_major_version = None - mac_version = None - requirements = [ - "pillow~=8.4.0", + "pillow~=9.0.1", "requests", - "matplotlib~=3.4.3", + "matplotlib~=3.5.1", ] -tf_req = "tensorflow~=2.5.0;platform_machine!='armv7l'" -onnx_req = "onnxruntime~=1.8.1;platform_machine!='armv7l'" -tflite_req = None - -# get the right TF Lite runtime packages based on OS and python version: https://www.tensorflow.org/lite/guide/python#install_just_the_tensorflow_lite_interpreter -tflite_python = None -tflite_platform = None -tflite_machine = None - -# get the right python string for the version -if python_version == '3.6': - tflite_python = 'cp36-cp36m' -elif python_version == '3.7': - tflite_python = 'cp37-cp37m' -elif python_version == '3.8': - tflite_python = 'cp38-cp38' -elif python_version == '3.9': - tflite_python = 'cp39-cp39' - -# get the right platform and machine strings for the tflite_runtime wheel URL -sys_platform = sys.platform.lower() -machine = platform.machine().lower() -if sys_platform == 'linux': - tflite_platform = sys_platform - tflite_machine = machine -elif sys_platform == 'win32': - tflite_platform = 'win' - tflite_machine = machine -elif sys_platform == 'darwin' and machine == 'x86_64': - if mac_version == '10.15': - tflite_platform = 'macosx_10_15' - elif mac_major_version == '11': - tflite_platform = 'macosx_11_0' - tflite_machine = machine - -# add it to the requirements, or print the location to find the version to install -if tflite_python and tflite_platform and tflite_machine: - tflite_req = f"tflite_runtime @ https://github.com/google-coral/pycoral/releases/download/v2.0.0/tflite_runtime-2.5.0.post1-{tflite_python}-{tflite_platform}_{tflite_machine}.whl" -else: - print( - f"Couldn't find tflite_runtime for your platform {sys.platform}, machine {platform.machine()}, python version {python_version}, and mac version {mac_version}. If you are trying to use TensorFlow Lite, please see the install guide for the right version: https://www.tensorflow.org/lite/guide/python#install_just_the_tensorflow_lite_interpreter" - ) +tf_req = "tensorflow~=2.8.0 ; platform_machine != 'armv7l'" +onnx_req = "onnxruntime~=1.10.0 ; platform_machine != 'armv7l' and python_version <= '3.9'" # onnxruntime not to 3.10 yet +tflite_req = "tflite-runtime~=2.7.0 ; platform_system == 'Linux' and python_version <= '3.9'" # tflite not to 3.10 yet setup( name="lobe", - version="0.6.1", + version="0.6.2", description="Lobe Python SDK", long_description=readme, long_description_content_type="text/markdown", + keywords='lobe ai machine learning', url="https://github.com/lobe/lobe-python", license="MIT", packages=find_packages("src"), package_dir={"": "src"}, install_requires=requirements, extras_require={ - 'all': [tf_req, onnx_req], + 'all': [tf_req, onnx_req, tflite_req], 'tf': [tf_req], 'onnx': [onnx_req], - } + 'tflite': [tflite_req], + }, + python_requires='>=3.7', + classifiers=sorted([ + 'Development Status :: 4 - Beta', + 'Intended Audience :: Developers', + 'Intended Audience :: Education', + 'Intended Audience :: Science/Research', + 'License :: OSI Approved :: MIT License', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3 :: Only', + 'Topic :: Scientific/Engineering', + 'Topic :: Scientific/Engineering :: Mathematics', + 'Topic :: Scientific/Engineering :: Artificial Intelligence', + 'Topic :: Software Development', + 'Topic :: Software Development :: Libraries', + 'Topic :: Software Development :: Libraries :: Python Modules', + ]), )