Giter VIP home page Giter VIP logo

lobe-python's Introduction

Lobe

Lobe is an easy-to-use tool that helps you train machine learning models on your own computer, for free, without any prior experience required. It runs locally on both Mac and PC, and you can ship your model to any platform you choose.

Download it for free to get started on your machine learning model today.

Machine Learning Made Easy

Lobe takes a new humane approach to machine learning by putting your images in the foreground and receding to the background, serving as the main bridge between your ideas and your machine learning model.

Lobe also simplifies the process of machine learning into three easy steps. Collect and label your images. Train and understand your results. Then play with your model and improve it.

image

lobe-python's People

Contributors

adammenges avatar adiazulay avatar marlinspike avatar mbeissinger avatar pikamander2 avatar shawncal avatar stevecheckoway avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lobe-python's Issues

Tflite-runtime 2.7.0 can't be installed

I run into this issue when installing the Lobe module on my Raspberry Pi. When running sudo ./lobe-rpi-install.sh I get to the following error:

Could not find a version that satisfies the requirement tflite-runtime~=2.7.0 (from lobe[tflite]) (from versions: 2.5.0)

I have tried updating though pip(3), removing and reinstalling and using the .whl files from PyPI. I also installed tensorflow itself. Whatever I try, I can't seem to get a higher version than 2.7.0. Is there something I'm missing?

I have the Raspberry Pi 3B with Raspian (32bit) and 1 GB of RAM.

Python 3.8 support?

Is there an ETA for when Python 3.8 will be supported? Tensorflow supports Python 3.8 now, so it would be nice to be able to use it.

Getting an IndexError from the tflite backend on Raspberry Pi

Traceback (most recent call last):
  File "/home/pi/Desktop/tester.py", line 6, in <module>
    result = model.predict_from_file('/home/pi/Desktop/image.png')
  File "/home/pi/.local/lib/python3.7/site-packages/lobe/ImageModel.py", line 43, in predict_from_file
    return self.predict(image_utils.get_image_from_file(path))
  File "/home/pi/.local/lib/python3.7/site-packages/lobe/ImageModel.py", line 47, in predict
    return self.__backend.predict(image_processed)
  File "/home/pi/.local/lib/python3.7/site-packages/lobe/backends/_backend_tflite.py", line 57, in predict
    output_details[1]["index"]
IndexError: list index out of range

Here is my code:

from lobe import ImageModel

model = ImageModel.load('/home/pi/Lobe/model')

result = model.predict_from_file('/home/pi/Desktop/image.png')
print(result.prediction)

Feature Request: Export/Import trained models as Keras HDF5 format

Currently, the lobe desktop application only exports the trained models as TensorFlow 1 data format. However, it would be nice to have an option to export the models as the Keras HDF5 format.

I have trained a model using lobe desktop application and want to save/load it as a Keras HDF5 format. I have tried the suggestion tensorflow/tensorflow#42425 without any luck.

Any comments on this from the team? Any workarounds?

ImportError: cannot import name '_imaging' from 'PIL

When running the example script on Windows 10 in a Python 3.8 virtual environment, I get this error:

Traceback (most recent call last):
  File "C:\Users\Pikamander2\Dropbox\Python\Image recognition\Lobe virtual environment 1\.venv\Lib\site-packages\lobe-test-1.py", line 1, in <module>
    from lobe import ImageModel
  File "C:\Users\Pikamander2\Dropbox\Python\Image recognition\Lobe virtual environment 1\.venv\Lib\site-packages\lobe\__init__.py", line 2, in <module>
    from .model.image_model import ImageModel
  File "C:\Users\Pikamander2\Dropbox\Python\Image recognition\Lobe virtual environment 1\.venv\Lib\site-packages\lobe\model\image_model.py", line 4, in <module>
    from PIL import Image
  File "C:\Users\Pikamander2\Dropbox\Python\Image recognition\Lobe virtual environment 1\.venv\Lib\site-packages\PIL\Image.py", line 94, in <module>
    from . import _imaging as core
ImportError: cannot import name '_imaging' from 'PIL' (C:\Users\Pikamander2\Dropbox\Python\Image recognition\Lobe virtual environment 1\.venv\Lib\site-packages\PIL\__init__.py)

Googling the error returns this Stack Overflow page, which suggests that PIL and Pillow are conflicting with each other.

image

Pip doesn't install tflite-runtime from dependency link

Pip doesn't find tflite-runtime from the dependency link in setup.py

This only affects armv7l devices which includes the Raspberry Pi

as a work around you can run:

pip3 install https://dl.google.com/coral/python/tflite_runtime-2.1.0.post1-cp37-cp37m-linux_armv7l.whl

Can not install SDK on Raspberry Pi

Why does it fail and what is needed to correct the load on a Raspberry pi
The SDK can not be loaded and errors out on the numpy load. The error says:

build/lib.linux-armv7l-3.7/numpy/core/_multiarray_umath.cpython-37m-arm-linux-gnueabihf.so" failed with exit status 1
Failed to build numpy
ERROR: Could not build wheels for numpy, which is required to install pyproject.toml-based projects
WARNING: You are using pip version 22.0.3; however, version 22.0.4 is available.
You should consider upgrading via the '/usr/bin/python3 -m pip install --upgrade pip' command.
When I check my version of pip it is the latest version
pi@pi:~ $ pip --version
pip 22.0.4 from /home/pi/.local/lib/python3.7/site-packages/pip (python 3.7)

Why does it fail and what is needed to correct the load on a Raspberry pi
Also note the raspberry pi version
PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster

ERROR: Could not find a version that satisfies the requirement git

When I try to run the Linux commands listed in the README.md, I get these errors:

pip3 install setuptools git
ERROR: Could not find a version that satisfies the requirement git (from versions: none)
ERROR: No matching distribution found for git
pip3 install git+https://github.com/lobe/lobe-python
ERROR: Error [Errno 2] No such file or directory: 'git' while executing command git clone -q https://github.com/lobe/lobe-python /tmp/pip-req-build-1qql06x2
ERROR: Cannot find command 'git' - do you have 'git' installed and in your PATH?

I'm using Ubuntu 20.04.1 LTS, Python 3.8.5, and pip 20.0.2.

any support for apple silicon?

Now we can install tensorflow on apple silicon by miniforge and apple/tensorflow-macos
But I dont know if there's any support for it.

Thanks.

Package 'libjpeg62-turbo' has no installation candidate on Ubuntu 20.04

astrr@Ubuntu:~$ sudo apt install -y
libatlas-base-dev
libopenjp2-7
libtiff5
libjpeg62-turbo
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package libjpeg62-turbo is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'libjpeg62-turbo' has no installation candidate

Error while predicting result

TypeError Traceback (most recent call last)
/tmp/ipykernel_35/1784468283.py in
1 result=[]
2 for i in test.filename:
----> 3 result_i= model.predict_from_file(i)
4 result.append(result_i.prediction)
5 print(result,len(result))

/opt/conda/lib/python3.7/site-packages/lobe/model/image_model.py in predict_from_file(self, path)
58
59 def predict_from_file(self, path: str):
---> 60 return self.predict(image_utils.get_image_from_file(path))
61
62 def predict(self, image: Image.Image) -> ClassificationResult:

/opt/conda/lib/python3.7/site-packages/lobe/model/image_model.py in predict(self, image)
61
62 def predict(self, image: Image.Image) -> ClassificationResult:
---> 63 image_processed = image_utils.preprocess_image(image, self.signature.input_image_size)
64 image_array = image_utils.image_to_array(image_processed)
65 results = self.backend.predict(image_array)

/opt/conda/lib/python3.7/site-packages/lobe/image_utils.py in preprocess_image(image, size)
83
84 def preprocess_image(image: Image.Image, size: Tuple[int, int]) -> Image.Image:
---> 85 image_processed = update_orientation(image)
86
87 # resize and crop image to the model's required size

/opt/conda/lib/python3.7/site-packages/lobe/image_utils.py in update_orientation(image)
47 exif_orientation_tag = 0x0112
48 if hasattr(image, '_getexif'):
---> 49 exif = image._getexif()
50 if exif != None and exif_orientation_tag in exif:
51 orientation = exif.get(exif_orientation_tag, 1)

/opt/conda/lib/python3.7/site-packages/PIL/JpegImagePlugin.py in _getexif(self)
473
474 def _getexif(self):
--> 475 return _getexif(self)
476
477 def _getmp(self):

/opt/conda/lib/python3.7/site-packages/PIL/JpegImagePlugin.py in _getexif(self)
496 if "exif" not in self.info:
497 return None
--> 498 return self.getexif()._get_merged_dict()
499
500

/opt/conda/lib/python3.7/site-packages/PIL/Image.py in getexif(self)
1322
1323 self.load()
-> 1324 if band is not None:
1325 return self.im.getband(band)
1326 return self.im # could be abused

/opt/conda/lib/python3.7/site-packages/PIL/Image.py in load(self, data)
3354 atexit.register(core.clear_cache)
3355
-> 3356
3357 class Exif(MutableMapping):
3358 endian = None

/opt/conda/lib/python3.7/site-packages/PIL/TiffImagePlugin.py in load(self, fp)
774 tag, typ, count, data = self._unpack("HHL4s", self._ensure_read(fp, 12))
775
--> 776 tagname = TiffTags.lookup(tag, self.group).name
777 typname = TYPES.get(typ, "unknown")
778 msg = f"tag: {tagname} ({tag}) - type: {typname} ({typ})"

TypeError: lookup() takes 1 positional argument but 2 were given

Kaggle : https://www.kaggle.com/gauravduttakiit/notebook52daed67ed

Originally posted by @GDGauravDutta in #25 (comment)

Tensor Flow bugs

2 bugs with Tensor flows:

  • Signature passes an os path instead of string
  • Tensors names haven't been updated for release version

Error while predicting result


TypeError Traceback (most recent call last)
in
10 img = Image.open('./{}'.format(a))
11 print(a)
---> 12 result = model.predict(img)
13 # Print top prediction
14 print('Model Prediction : {}'.format(result.prediction))

/opt/conda/lib/python3.7/site-packages/lobe/model/image_model.py in predict(self, image)
45
46 def predict(self, image: Image.Image) -> ClassificationResult:
---> 47 image_processed = image_utils.preprocess_image(image, self.signature.input_image_size)
48 image_array = image_utils.image_to_array(image_processed)
49 results = self.backend.predict(image_array)

/opt/conda/lib/python3.7/site-packages/lobe/image_utils.py in preprocess_image(image, size)
83
84 def preprocess_image(image: Image.Image, size: Tuple[int, int]) -> Image.Image:
---> 85 image_processed = update_orientation(image)
86
87 # resize and crop image to the model's required size

/opt/conda/lib/python3.7/site-packages/lobe/image_utils.py in update_orientation(image)
47 exif_orientation_tag = 0x0112
48 if hasattr(image, '_getexif'):
---> 49 exif = image._getexif()
50 if exif != None and exif_orientation_tag in exif:
51 orientation = exif.get(exif_orientation_tag, 1)

/opt/conda/lib/python3.7/site-packages/PIL/JpegImagePlugin.py in _getexif(self)
473
474 def _getexif(self):
--> 475 return _getexif(self)
476
477 def _getmp(self):

/opt/conda/lib/python3.7/site-packages/PIL/JpegImagePlugin.py in _getexif(self)
496 if "exif" not in self.info:
497 return None
--> 498 return self.getexif()._get_merged_dict()
499
500

/opt/conda/lib/python3.7/site-packages/PIL/Image.py in getexif(self)
1322 return self.im # could be abused
1323
-> 1324 def getextrema(self):
1325 """
1326 Gets the the minimum and maximum pixel values for each band in

/opt/conda/lib/python3.7/site-packages/PIL/Image.py in load(self, data)
3354 self._data = {}
3355 self._ifds = {}
-> 3356 self._info = None
3357 self._loaded_exif = None
3358

/opt/conda/lib/python3.7/site-packages/PIL/TiffImagePlugin.py in load(self, fp)
766 tag, typ, count, data = self._unpack("HHL4s", self._ensure_read(fp, 12))
767
--> 768 tagname = TiffTags.lookup(tag, self.group).name
769 typname = TYPES.get(typ, "unknown")
770 msg = f"tag: {tagname} ({tag}) - type: {typname} ({typ})"

TypeError: lookup() takes 1 positional argument but 2 were given

Unsupported on Python 3.10

I have a working Lobe install on Python 3.9.5. Attempting pip install lobe[tf] on Python 3.10.2 fails with the following error:

ERROR: Cannot install lobe[tf]==0.2.0, lobe[tf]==0.2.1, lobe[tf]==0.3.0, lobe[tf]==0.4.0, lobe[tf]==0.5.0, lobe[tf]==0.6.0 and lobe[tf]==0.6.1 because these package versions have conflicting dependencies.

The conflict is caused by:
    lobe[tf] 0.6.1 depends on tensorflow~=2.5.0; platform_machine != "armv7l" and extra == "tf"
    lobe[tf] 0.6.0 depends on tensorflow~=2.5.0; platform_machine != "armv7l" and extra == "tf"
    lobe[tf] 0.5.0 depends on tensorflow~=2.5.0; platform_machine != "armv7l" and extra == "tf"
    lobe[tf] 0.4.0 depends on onnxruntime~=1.7.0; platform_machine != "armv7l"
    lobe[tf] 0.3.0 depends on tensorflow==2.4; platform_machine != "armv7l"
    lobe[tf] 0.2.1 depends on tensorflow<2 and >=1.15.2; platform_machine != "armv7l"
    lobe[tf] 0.2.0 depends on tensorflow<2 and >=1.15.2; platform_machine != "armv7l"

To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict

It seems that tensorflow==2.5.0 fails as well:

ERROR: Could not find a version that satisfies the requirement tensorflow==2.5.0 (from versions: 2.8.0rc1, 2.8.0)
ERROR: No matching distribution found for tensorflow==2.5.0

Any thoughts? It's possible I've misconfigured something here.

Heatmap is not displayed

The visualization is done using a model created in Lobe.
I tried to get a heatmap using the usage code but what was displayed was a slightly darkened original image.

from lobe import ImageModel
from PIL import Image
import os
import sys
os.environ["CUDA_VISIBLE_DEVICES"] = "-1"
mePath = os.path.dirname(file)
model = ImageModel.load('path/to/exported/model/folder')
img = Image.open('path/to/file.jpg')
result = model.predict(img)
img.show()

print(result.prediction)

for label, confidence in result.labels:
print(f"{label}: {confidence*100}%")

heatmap = model.visualize(img)
heatmap.show()

I added a sentence to display heatmap_img at line 162 of image_model.py to test it, and found that heatmap_img was completely dark.

heatmap_img = heatmap_img.resize((height, width))
heatmap_img .show()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.