lobe-python 0.3 refactor by mbeissinger · Pull Request #15 · lobe/lobe-python · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 32 additions & 19 deletions README.md
12 changes: 12 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Release 0.3.0
___
## Breaking Changes
* Previous use of Signature should be ImageClassificationSignature. `from lobe.signature import Signature` ->
`from lobe.signature import ImageClassificationSignature`

## Bug Fixes and Other Improvements
* Update to TensorFlow 2.4 from 1.15.4
* Add ONNX runtime backend
* Use requests instead of urllib
* Make backends thread-safe
* Added constants file for signature keys to enable backwards-compatibility
6 changes: 3 additions & 3 deletions examples/basic_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
result = model.predict_from_file('path/to/file.jpg')

# Predict from an image url
result = model.predict_from_url('http://path/to/file.jpg')
result = model.predict_from_url('http://url/to/file.jpg')

# Predict from Pillow image
from PIL import Image
Expand All @@ -18,5 +18,5 @@
print("Top prediction:", result.prediction)

# Print all classes
for label, prop in result.labels:
print(f"{label}: {prop*100:.6f}%")
for label, confidence in result.labels:
print(f"{label}: {confidence*100:.6f}%")
61 changes: 49 additions & 12 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,55 @@
from setuptools import setup, find_packages
import sys
import platform


python_version = platform.python_version().rsplit('.', maxsplit=1)[0]

requirements = [
"pillow",
"requests",
"numpy==1.19.3",
"tensorflow==2.4;platform_machine!='armv7l'",
"onnxruntime==1.6.0;platform_machine!='armv7l'"
]

# 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_machine = None

# get the right python string for the version
if python_version == '3.5':
tflite_python = 'cp35-cp35m'
elif 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'

# get the right machine string
if sys.platform == 'win32':
tflite_machine = 'win_amd64'
elif sys.platform == 'darwin':
tflite_machine = 'macosx_10_15_x86_64'
elif sys.platform == 'linux':
if platform.machine() == 'x86_64':
tflite_machine = 'linux_x86_64'
elif platform.machine() == 'armv7l':
tflite_machine = 'linux_armv7l'

# add it to the requirements, or print the location to find the version to install
if tflite_python and tflite_machine:
requirements.append(f"tflite_runtime @ https://github.com/google-coral/pycoral/releases/download/release-frogfish/tflite_runtime-2.5.0-{tflite_python}-{tflite_machine}.whl")
else:
print(
f"Couldn't find tflite_runtime for your platform {sys.platform}, machine {platform.machine()}, and python version {python_version}, please see the install guide for the right version: https://www.tensorflow.org/lite/guide/python#install_just_the_tensorflow_lite_interpreter"
)

setup(
name="lobe",
version="0.2.1",
version="0.3.0",
packages=find_packages("src"),
package_dir={"": "src"},
install_requires=[
"numpy",
"pillow",
"requests",
"tensorflow>=1.15.2,<2;platform_machine!='armv7l'",
"tflite_runtime ; platform_machine=='armv7l'"
],
dependency_links=[
"https://www.piwheels.org/simple/tensorflow",
"https://dl.google.com/coral/python/tflite_runtime-2.1.0.post1-cp37-cp37m-linux_armv7l.whl"
]
install_requires=requirements,
)
47 changes: 0 additions & 47 deletions src/lobe/ImageModel.py

This file was deleted.

89 changes: 0 additions & 89 deletions src/lobe/Signature.py

This file was deleted.

2 changes: 2 additions & 0 deletions src/lobe/__init__.py
24 changes: 0 additions & 24 deletions src/lobe/_model.py

This file was deleted.

Loading