Code Monkey home page Code Monkey logo

coral-pi-rest-server's People

Contributors

lmamakos avatar mtyka avatar robmarkcole avatar sstratoti 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

coral-pi-rest-server's Issues

issue with the docker

Hi robmarcole,
I tried to use your docker, but when I start it I receive the following errors:

Traceback (most recent call last):
File "coral-app.py", line 84, in
engine = DetectionEngine(MODEL_FILE)
File "/usr/local/lib/python3.6/site-packages/edgetpu/detection/engine.py", line 72, in init
super().init(model_path)
File "/usr/local/lib/python3.6/site-packages/edgetpu/basic/basic_engine.py", line 40, in init
self._engine = BasicEnginePythonWrapper.CreateFromFile(model_path)
RuntimeError: Could not open '/home/robin/edgetpu/all_models/mobilenet_ssd_v2_coco_quant_postprocess_edgetpu.tflite'.

please could you help me to understand how can I fix this issue on my debian?
Thank you

To do - on device classification retrain

https://coral.withgoogle.com/docs/edgetpu/retrain-classification-ondevice/

Classification is suitable in the home automation context where a typical use case is to filter images captured by motion activated cameras, or determine some binary state (e.g. garrage door open/closed). The drawbacks of this technique are not a problem in this context, where we typically dont want to have to create massive datasets, and also we expect datasets to have a small inner class variation. The docs state 'However, this method works well when the training images (and the images to classify) have less variations. And in such case, only a few images (less than 10) are needed to train. For example, when an assembly-line produces a new type of defective part, you can use this method to teach the device what a defective part looks like on the fly.'

requirements.txt needs numpy

I think that requirements.txt needs to include numpy. While starting coral-app.py inside a container with only Flask and Pillow installed I note that something in the edgetpu library has a dependency on it:

root@8d34eb5617d9:/home/pi# python coral-app.py
ImportError: numpy.core.multiarray failed to import
Traceback (most recent call last):
  File "coral-app.py", line 6, in <module>
    from edgetpu.detection.engine import DetectionEngine
  File "/usr/local/lib/python3.6/site-packages/edgetpu/detection/engine.py", line 17, in <module>
    from edgetpu.basic.basic_engine import BasicEngine
  File "/usr/local/lib/python3.6/site-packages/edgetpu/basic/basic_engine.py", line 17, in <module>
    from edgetpu.swig.edgetpu_cpp_wrapper import BasicEnginePythonWrapper
  File "/usr/local/lib/python3.6/site-packages/edgetpu/swig/edgetpu_cpp_wrapper.py", line 28, in <module>
    _edgetpu_cpp_wrapper = swig_import_helper()
  File "/usr/local/lib/python3.6/site-packages/edgetpu/swig/edgetpu_cpp_wrapper.py", line 24, in swig_import_helper
    _mod = imp.load_module('_edgetpu_cpp_wrapper', fp, pathname, description)
  File "/usr/local/lib/python3.6/imp.py", line 243, in load_module
    return load_dynamic(name, filename, file)
  File "/usr/local/lib/python3.6/imp.py", line 343, in load_dynamic
    return _load(spec)
ImportError: numpy.core.multiarray failed to import

Adding that back to requirements.txt resolves this problem.

coral flask server hangs after a while

I've noticed that in my environment, the coral TPU stick goes into an unusual state and the flask server ceases responding to requests. I'm running this in a Docker container on Ubuntu 18.04 on Intel Core i5.

Of note that when it gets into this state, the white LED on the Coral TPU USB stick has this consistent blinking going on. I've tried to figure out what the LED state is supposed to represent, but haven't obviously found documentation to that effect. Any insight here would be useful.

I've added a healthcheck to the docker container, which successfully noticed that the server isn't responding to queries. Too bad it doesn't automatically restart the container :-) I think that I need to be running docker swarm or something a bit more sophisticated for the automatic restart...

Of course I'm away on travel, so debugging is limited. I need to sync-up versions of what I'm running with the most recent version here, and also look at some suspicious/weirdness in terms of what packages are being installed into the container by the coral install script. I fear there might be a mix of Python 3.6 and 3.7 stuff going on in there, and I'm not 100% clear on what's being used. Of course, I'd think that obvious dependency issues would be evident right away, not days later after the container has been running.

I wanted to just open an issue here as a place-keeper and also see if anyone else might have noticed similar behavior in an attempt to shorten up some debugging steps.

To do - add demo scripts

Add a folder with demo scripts showing the usage of the rest-server. Ideas include

  • Script which takes an image, processes it, and generates an annotated jpg

  • Script for exposing the image as mjpeg stream/posting over mqtt

Buster is bust

As title, appears the coral build scripts haven't been updated for Buster yet. Track progress here. My error:

pi@tpu-pi:/usr/local/lib/python3.7/dist-packages/edgetpu/demo $ python3 classify_image.py \
> --model ~/Downloads/mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite \
> --label ~/Downloads/inat_bird_labels.txt \
> --image ~/Downloads/parrot.jpg
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/edgetpu/swig/edgetpu_cpp_wrapper.py", line 18, in swig_import_helper
    fp, pathname, description = imp.find_module('_edgetpu_cpp_wrapper', [dirname(__file__)])
  File "/usr/lib/python3.7/imp.py", line 296, in find_module
    raise ImportError(_ERR_MSG.format(name), name=name)
ImportError: No module named '_edgetpu_cpp_wrapper'

Docker container error

I am getting:

(base) robin@robins-ubuntu:~/Github/coral-pi-rest-server$ sudo docker run -p 5000:5000 --device /dev/bus/usb:/dev/bus/usb   coral:latest
Traceback (most recent call last):
  File "coral-app.py", line 122, in <module>
    load_model(args.model, args.labels)
  File "coral-app.py", line 48, in load_model
    engine = DetectionEngine(model_file)
  File "/usr/local/lib/python3.6/site-packages/edgetpu/detection/engine.py", line 55, in __init__
    super().__init__(model_path)
  File "/usr/local/lib/python3.6/site-packages/edgetpu/swig/edgetpu_cpp_wrapper.py", line 300, in __init__
    this = _edgetpu_cpp_wrapper.new_BasicEngine(*args)
RuntimeError: Failed to allocate tensors.

Any ideas @lmamakos ?

<FileStorage: 'image' (None)>

Server times out and I see

192.168.1.164 - - [10/Aug/2019 18:37:31] "POST /v1/vision/detection HTTP/1.1" 200 -
<FileStorage: 'image' (None)>
192.168.1.164 - - [10/Aug/2019 18:39:03] "POST /v1/vision/detection HTTP/1.1" 200 -
<FileStorage: 'image' (None)>
192.168.1.164 - - [11/Aug/2019 09:56:44] "POST /v1/vision/detection HTTP/1.1" 200 -
<FileStorage: 'image' (None)>
<FileStorage: 'image' (None)>

USB Transfer Error

Hi - Im getting the error message that you noted in your troubleshooting. It says to reflash the SD card. What does reflash the SC card mean?

Q: I get the error: HandleQueuedBulkIn transfer in failed. Not found: USB transfer error 5 [LibUsbDataInCallback] A: I reflashed the SD card and tried again with success

Thanks.

To do

  • Tests

  • Basic username/password auth

  • Server status endpoint

Raspberry pi specific instructions for Docker

As per #13 you cant currently use the coral with system-wide python in Buster, so the recommended solution is Docker on the pi. @lmamakos can we have a single docker image that will work on Ubuntu & Raspbian? If not will we require hardware specific instructions on building the container?

Change font size on bounding boxes.

re: Coral rest server

there any way to make the font larger and/or a different color background on the boxes? I’m not able to read anything on any detections, possibly b/c I’ve reduced the camera image to VGA resolution (and the bitrate is now 96kbps on the sub stream) as its a wifi camera and the link isn’t great. This solved some of my delay problems and timeouts:

I’d like to move them to the bottom instead of the top of the image as well.

If you can just point me to the module that handles these drawing routines, I should be able to figure it out from there.

Jeff

Make ROOT_URL configurable

We had /predict, now /v1/vision/detection. Makes sense to have this as configurable as this would allow people to easily integrate the endpoints into their existing flask apps

ImportError: numpy.core.multiarray failed to import

following your guide, i'm trying to run python3 coral-app.py but i get this:

pi@raspberrypi:~/coral-pi-rest-server $ python3 coral-app.py ImportError: numpy.core.multiarray failed to import Traceback (most recent call last): File "coral-app.py", line 6, in <module> from edgetpu.detection.engine import DetectionEngine File "/usr/local/lib/python3.5/dist-packages/edgetpu/detection/engine.py", line 17, in <module> from edgetpu.basic.basic_engine import BasicEngine File "/usr/local/lib/python3.5/dist-packages/edgetpu/basic/basic_engine.py", line 17, in <module> from edgetpu.swig.edgetpu_cpp_wrapper import BasicEnginePythonWrapper File "/usr/local/lib/python3.5/dist-packages/edgetpu/swig/edgetpu_cpp_wrapper.py", line 28, in <module> _edgetpu_cpp_wrapper = swig_import_helper() File "/usr/local/lib/python3.5/dist-packages/edgetpu/swig/edgetpu_cpp_wrapper.py", line 24, in swig_import_helper _mod = imp.load_module('_edgetpu_cpp_wrapper', fp, pathname, description) File "/usr/lib/python3.5/imp.py", line 242, in load_module return load_dynamic(name, filename, file) File "/usr/lib/python3.5/imp.py", line 342, in load_dynamic return _load(spec) ImportError: numpy.core.multiarray failed to import

i'm on standard Raspbian GNU/Linux 9 (stretch) ( Raspberry 3+)
i've installed the Edge TPU runtime and Python library from the coral site
any idea?

this is my home structure:

pi@raspberrypi:~ $ ls
all_models            env               start_assistant.sh
coral-pi-rest-server  googleassistant   Templates
Desktop               Music             tv_grab_italy_basic_url.py
Documents             Pictures          tv_grab_italy_sky_url.py
Downloads             Public            Videos
edgetpu_api           Python-3.6.8
edgetpu_api.tar.gz    Python-3.6.8.tgz

Bounding box computation seems wrong

I made this change:

--- coral-app.py.original	2019-06-07 00:07:28.942209359 -0400
+++ coral-app.py	2019-06-07 00:22:49.023841467 -0400
@@ -83,8 +83,8 @@

                     bounding_box = {
                         "x1": round(prediction.bounding_box[0, 0], DECIMALS),
-                        "x2": round(prediction.bounding_box[0, 1], DECIMALS),
-                        "y1": round(prediction.bounding_box[1, 0], DECIMALS),
+                        "x2": round(prediction.bounding_box[1, 0], DECIMALS),
+                        "y1": round(prediction.bounding_box[0, 1], DECIMALS),
                         "y2": round(prediction.bounding_box[1, 1], DECIMALS),
                     }
                     preds.append(

and now the bounding boxes seem to line up better..

Coral stick becomes unresponsive

Using sudo systemctl start coral.service the app appears to die after 12 hours, no errors in logs, just doesn't respond to requests

Mac support

Can we support coral on mac via docker? Seems we should be able to, I'm not sure how we mount the USB however

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.