Skip to content

Commit

Permalink
Update requirements to latest versions, change tflite-runtime to pypi…
Browse files Browse the repository at this point in the history
… install, add tags to setup.py (#33)
  • Loading branch information
mbeissinger authored Feb 23, 2022
1 parent ef812da commit bf0c581
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 69 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ venv.bak/
.v37
.v38
.v39
.v310

# Spyder project settings
.spyderproject
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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]
Expand Down
8 changes: 8 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 2 additions & 4 deletions scripts/lobe-rpi-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
# Install lobe-python to use the tflite backend
sudo pip3 install lobe[tflite]
91 changes: 30 additions & 61 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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',
]),
)

0 comments on commit bf0c581

Please sign in to comment.