Giter Site home page Giter Site logo

edjeelectronics / tensorflow-object-detection-on-the-raspberry-pi Goto Github PK

View Code? Open in Web Editor NEW
1.1K 1.1K 364.0 6.26 MB

A tutorial showing how to set up TensorFlow's Object Detection API on the Raspberry Pi

License: Apache License 2.0

Python 100.00%

tensorflow-object-detection-on-the-raspberry-pi's People

Contributors

davidbradway avatar edjeelectronics avatar ladyada 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  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

tensorflow-object-detection-on-the-raspberry-pi's Issues

Step 6: python3 Object_detection_picamera.py

Please note I followed the tutorial step by step apart from ignoring step 3 'git checkout v1.8.0', it resulted to deletion of previously downloaded files as highlighted in issue 1. Again very grateful to your efforts @EdjeElectronics .
Running the command 'python3 Object_detection_picamera.py ' generated the following error.
image What would be the best foot forward? Thanks

Some notes:
(Not sure if relevant) On checking the files (not sure if what I didnt was correct) i noticed there is no file with 'string_int_label_map_pb2' but found 'string_int_label_map.proto'.

headless object_detection.py possible?

hi,
do you think your script could run on my (everbodies?) headless raspberry-pi?
and save a image-snapshot if an object is detected?

any ideas how to realize that (sorry, i am no coder...)..

thanks, if you find time to answer...
tozett

Traceback (most recent call last): error

I have rasspery pi zero,
I did everything as you show (set related step arm6l for rasperry pi zero only)
When I write the command "python3 Object_detection_picamera.py" I got these error.
How can I fix it.
(Also I have picamera and test it, it is working)
Thanks.

pi@raspberrypi:~/tensorflow1/models/research/object_detection $ python3 Object_detection_picamera.py
Traceback (most recent call last):
  File "Object_detection_picamera.py", line 84, in <module>
    serialized_graph = fid.read()
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/lib/io/file_io.py", line 120, in read
    self._preread_check()
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/lib/io/file_io.py", line 80, in _preread_check
    compat.as_bytes(self.__name), 1024 * 512, status)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/errors_impl.py", line 519, in __exit__
    c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.NotFoundError: /home/pi/tensorflow1/models/research/object_detection/ssdlite_mobilenet_v2_coco_2018_05_09/frozen_inference_graph.pb; No such file or directory

BGR or RGB?

Thank you for the great tutorial!
I have a question: your code gets the image in BGR (for both the picamera and USB). I thought that the tensorflow pre-built models expect RGB.

Don't you need to convert (e.g. frame= frame[:, :, [2, 1, 0]]) ?

please help

Traceback (most recent call last):
File "Object_detection_picamera.py", line 86, in
tf.import_graph_def(od_graph_def, name='')
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/importer.py", line 280, in import_graph_def
raise ValueError('No op named %s in defined operations.' % node.op)
ValueError: No op named NonMaxSuppressionV2 in defined operations.

File "/home/pi/.local/lib/python3.5/site-packages/picamera/camera.py", line 1704, in capture_continuous 'Timed out waiting for capture to end')

I followed the tutorial to the letter, and I'm so close! When I run "python3 Object_detection_picamera.py" I get the following. This website seems to indicate that it's a truncation problem. I'm not sure what to make of it, because your code looks like it's already doing what the link suggests.

My Pi Camera is an older Rev 1.3, would that matter? Using a RPi3 otherwise.

Traceback (most recent call last):
File "/home/pi/.local/lib/python3.5/site-packages/picamera/camera.py", line 1704, in capture_continuous
'Timed out waiting for capture to end')
picamera.exc.PiCameraRuntimeError: Timed out waiting for capture to end

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "Object_detection_picamera.py", line 130, in
for frame1 in camera.capture_continuous(rawCapture, format="bgr",use_video_port=True):
File "/home/pi/.local/lib/python3.5/site-packages/picamera/camera.py", line 1710, in capture_continuous
encoder.close()
File "/home/pi/.local/lib/python3.5/site-packages/picamera/encoders.py", line 431, in close
self.stop()
File "/home/pi/.local/lib/python3.5/site-packages/picamera/encoders.py", line 419, in stop
self._close_output()
File "/home/pi/.local/lib/python3.5/site-packages/picamera/encoders.py", line 349, in _close_output
mo.close_stream(output, opened)
File "/home/pi/.local/lib/python3.5/site-packages/picamera/mmalobj.py", line 371, in close_stream
stream.flush()
File "/home/pi/.local/lib/python3.5/site-packages/picamera/array.py", line 238, in flush
self.array = bytes_to_rgb(self.getvalue(), self.size or self.camera.resolution)
File "/home/pi/.local/lib/python3.5/site-packages/picamera/array.py", line 127, in bytes_to_rgb
'Incorrect buffer length for resolution %dx%d' % (width, height))
picamera.exc.PiCameraValueError: Incorrect buffer length for resolution 1280x720

research folder issue

Hi, I downloaded models.git by issuing
git clone --recurse-submodules https://github.com/tensorflow/models.git but in the other step cd /home/pi/tensorflow1/models/research I took there was no such directory error even if I checked the models folders manually. So, I can't find the research file in my folders. Can anyone help me?

" sudo pip3 install jupyter" command is failed on Raspbian OS

When I ran " sudo pip3 install jupyter" command, I had got the below error message.

  • System environment
pi@raspberrypi:~ $ cat /etc/debian_version
9.8
pi@raspberrypi:~ $ cat /etc/*release*
PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)"
NAME="Raspbian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"
pi@raspberrypi:~ $

  • Log message:
 . . . OMISSION . . . 
Collecting nbformat>=4.4 (from nbconvert->jupyter)
  Using cached https://files.pythonhosted.org/packages/da/27/9a654d2b6cc1eaa517d1c5a4405166c7f6d72f04f6e7eea41855fe808a46/nbformat-4.4.0-py2.py3-none-any.whl
Collecting jupyter-core (from nbconvert->jupyter)
  Downloading https://files.pythonhosted.org/packages/1d/44/065d2d7bae7bebc06f1dd70d23c36da8c50c0f08b4236716743d706762a8/jupyter_core-4.4.0-py2.py3-none-any.whl (126kB)
    100% |################################| 133kB 236kB/s
Collecting pandocfilters>=1.4.1 (from nbconvert->jupyter)
Exception:
Traceback (most recent call last):
  File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 594, in urlopen
    chunked=chunked)
  File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 391, in _make_request
    six.raise_from(e, None)
  File "<string>", line 2, in raise_from
  File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 387, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib/python3.5/http/client.py", line 1198, in getresponse
    response.begin()
  File "/usr/lib/python3.5/http/client.py", line 297, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.5/http/client.py", line 266, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/usr/lib/python3/dist-packages/pip/commands/install.py", line 353, in run
    wb.build(autobuilding=True)
  File "/usr/lib/python3/dist-packages/pip/wheel.py", line 749, in build
    self.requirement_set.prepare_files(self.finder)
  File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 380, in prepare_files
    ignore_dependencies=self.ignore_dependencies))
  File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 554, in _prepare_file
    require_hashes
  File "/usr/lib/python3/dist-packages/pip/req/req_install.py", line 278, in populate_link
    self.link = finder.find_requirement(self, upgrade)
  File "/usr/lib/python3/dist-packages/pip/index.py", line 465, in find_requirement
    all_candidates = self.find_all_candidates(req.name)
  File "/usr/lib/python3/dist-packages/pip/index.py", line 423, in find_all_candidates
    for page in self._get_pages(url_locations, project_name):
  File "/usr/lib/python3/dist-packages/pip/index.py", line 568, in _get_pages
    page = self._get_page(location)
  File "/usr/lib/python3/dist-packages/pip/index.py", line 683, in _get_page
    return HTMLPage.get_page(link, session=self.session)
  File "/usr/lib/python3/dist-packages/pip/index.py", line 792, in get_page
    "Cache-Control": "max-age=600",
  File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/sessions.py", line 501, in get
    return self.request('GET', url, **kwargs)
  File "/usr/lib/python3/dist-packages/pip/download.py", line 386, in request
    return super(PipSession, self).request(method, url, *args, **kwargs)
  File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/sessions.py", line 488, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/sessions.py", line 609, in send
    r = adapter.send(request, **kwargs)
  File "/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/adapter.py", line 47, in send
    resp = super(CacheControlAdapter, self).send(request, **kw)
  File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/adapters.py", line 423, in send
    timeout=timeout
  File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 643, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/util/retry.py", line 315, in increment
    total -= 1
TypeError: unsupported operand type(s) for -=: 'Retry' and 'int'
pi@raspberrypi:~ $

cat-pet detector.py error: frame.setFlags

i wanted to try cat-detection,
(object-detection already running fine)
disabled twilio in the script, but got this error:

root@raspimax7219:/usr/src/tensorflow1/models/research/object_detection# python3 Pet_detector.py
Traceback (most recent call last):
  File "Pet_detector.py", line 275, in <module>
    frame.setflags(write=1)
ValueError: cannot set WRITEABLE flag to True of this array
root@raspimax7219:/usr/src/tensorflow1/models/research/object_detection#

may you can help me out, shorthand?
dont understand the array-constrution...but you?
what to do here?

thanks,
tozett

ImportError: numpy.core.multiarray failed to import

Followed guide and everything looks good, but when I run python3 Object_detection_picamera.py I get the following:

ImportError: numpy.core.multiarray failed to import
Traceback (most recent call last):
File "Object_detection_picamera.py", line 23, in
import cv2
File "/home/pi/.local/lib/python3.5/site-packages/cv2/init.py", line 3, in
from .cv2 import *
ImportError: numpy.core.multiarray failed to import

No Picamera Module

Picamera works when I take a raspistill, but the script fails at "from picamera.array import piRGBArray" with "ImportError: No Module named 'picamera'

I'm using a virtual env, not sure if that is why.

Any ideas?

Traceback (most recent call last)

can u please fix this error sir!!

Traceback (most recent call last):
File "Object_detection_picamera.py", line 51, in
from utils import label_map_util
File "/home/pi/tensorflow1/models/research/object_detection/utils/label_map_util.py", line 21, in
from object_detection.protos import string_int_label_map_pb2
ImportError: cannot import name 'string_int_label_map_pb2'

Low FPS

Hello,

My framerate is 0.05 which is very. I'm running a Raspberry PI 3+

What can I do to improve the framerate ?

'image_tensor' not existing in the graph

Hi Edje!

Trying to use a custom model, but I'm receiving an error about 'image_tensor' not existing in the graph.

KeyError: "The name 'image_tensor:0' refers to a Tensor which does not exist. The operation, 'image_tensor', does not exist in the graph."

Full console output here

I trained the model following Google's TensorFlow for Poets tutorial. The output was a .pb for the graph and a .txt with the labels. It didn't have the labels formatted the same way yours did, so manually edited it in.

Do you think something else might be missing from the retraining?

Any help would be much appreciated! Your example worked GREAT, now it's just to add in the custom model!

Thank you,
-RobotGrrl

Setup error: TypeError: unsupported operand type(s) for -=: 'Retry' and 'int'

When I push "sudo pip3 install pillow lxml jupyter matplotlib cython" I get this error:
`
Collecting defusedxml (from nbconvert->jupyter)
Downloading https://files.pythonhosted.org/packages/06/74/9b387472866358ebc08732de3da6dc48e44b0aacd2ddaa5cb85ab7e986a2/defusedxml-0.6.0-py2.py3-none-any.whl
Collecting widgetsnbextension~=3.4.0 (from ipywidgets->jupyter)
Exception:
Traceback (most recent call last):
File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 594, in urlopen
chunked=chunked)
File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 391, in _make_request
six.raise_from(e, None)
File "", line 2, in raise_from
File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 387, in _make_request
httplib_response = conn.getresponse()
File "/usr/lib/python3.5/http/client.py", line 1198, in getresponse
response.begin()
File "/usr/lib/python3.5/http/client.py", line 297, in begin
version, status, reason = self._read_status()
File "/usr/lib/python3.5/http/client.py", line 266, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/usr/lib/python3/dist-packages/pip/commands/install.py", line 353, in run
wb.build(autobuilding=True)
File "/usr/lib/python3/dist-packages/pip/wheel.py", line 749, in build
self.requirement_set.prepare_files(self.finder)
File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 554, in _prepare_file
require_hashes
File "/usr/lib/python3/dist-packages/pip/req/req_install.py", line 278, in populate_link
self.link = finder.find_requirement(self, upgrade)
File "/usr/lib/python3/dist-packages/pip/index.py", line 465, in find_requirement
all_candidates = self.find_all_candidates(req.name)
File "/usr/lib/python3/dist-packages/pip/index.py", line 423, in find_all_candidates
for page in self._get_pages(url_locations, project_name):
File "/usr/lib/python3/dist-packages/pip/index.py", line 568, in _get_pages
page = self._get_page(location)
File "/usr/lib/python3/dist-packages/pip/index.py", line 683, in _get_page
return HTMLPage.get_page(link, session=self.session)
File "/usr/lib/python3/dist-packages/pip/index.py", line 792, in get_page
"Cache-Control": "max-age=600",
File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/sessions.py", line 501, in get
return self.request('GET', url, **kwargs)
File "/usr/lib/python3/dist-packages/pip/download.py", line 386, in request
return super(PipSession, self).request(method, url, *args, **kwargs)
File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/sessions.py", line 488, in request
resp = self.send(prep, **send_kwargs)
File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/sessions.py", line 609, in send
r = adapter.send(request, **kwargs)
File "/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/adapter.py", line 47, in send
resp = super(CacheControlAdapter, self).send(request, **kw)
File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/adapters.py", line 423, in send
timeout=timeout
File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 643, in urlopen
_stacktrace=sys.exc_info()[2])
File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/util/retry.py", line 315, in increment
total -= 1
TypeError: unsupported operand type(s) for -=: 'Retry' and 'int'
`

RPi 3B+ & using tensorflow-1.13.1-cp35-none-linux_armv7l.whl

Runtime difference

When issueing
python3 Object_detection_picamera.py --usbcam

this error appears:

/usr/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning: compiletime version 3.4 of module 'tensorflow.python.framework.fast_tensor_util' does not match runtime version 3.5
  return f(*args, **kwds)
/usr/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning: builtins.type size changed, may indicate binary incompatibility. Expected 432, got 412
  return f(*args, **kwds)

How to recompile tensorflow for runtime 3.5?

SD card Image

Do you have SD card image that we can download and try immediately?
so that we can save time downloading and compiling?

tensorflow

Hi !!! I am a little bit confused !!!!
What is the difference between tensorflow object detection API and SSD Mobile net ( written in tensorflow)? are they the same thing?

Detect human only and trigger gpio

How can I modify the code to make the camera detect human only. And it can trigger gpio when the number of detected human goes to certain number such as 5?

VIDIOC_REQBUFS: No such device

Hi, I'm trying this on my raspberry pi however I'm getting some erros that I solver but this one I cannot see what is the problem.
So, I run this pi@raspberrypi:~/tensorflow1/models/research/object_detection $ python3 Object_detection_picamera.py --usbcam

and after a while I get the camera image, but 10 sec later I got an error: pi@raspberrypi:~/tensorflow1/models/research/object_detection $ python3 Object_detection_picamera.py --usbcam /usr/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning: compiletime version 3.4 of module 'tensorflow.python.framework.fast_tensor_util' does not match runtime version 3.5 return f(*args, **kwds) /usr/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning: builtins.type size changed, may indicate binary incompatibility. Expected 432, got 412 return f(*args, **kwds) 2019-05-16 09:51:51.406156: W tensorflow/core/framework/allocator.cc:124] Allocation of 8640000 exceeds 10% of system memory. 2019-05-16 09:51:52.530344: W tensorflow/core/framework/allocator.cc:124] Allocation of 8640000 exceeds 10% of system memory. 2019-05-16 09:51:53.278628: W tensorflow/core/framework/allocator.cc:124] Allocation of 8640000 exceeds 10% of system memory. 2019-05-16 09:51:54.004618: W tensorflow/core/framework/allocator.cc:124] Allocation of 8640000 exceeds 10% of system memory. 2019-05-16 09:51:54.737953: W tensorflow/core/framework/allocator.cc:124] Allocation of 8640000 exceeds 10% of system memory. VIDIOC_DQBUF: No such device Traceback (most recent call last): File "Object_detection_picamera.py", line 192, in <module> feed_dict={image_tensor: frame_expanded}) File "/home/pi/.local/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 929, in run run_metadata_ptr) File "/home/pi/.local/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1121, in _run np_val = np.asarray(subfeed_val, dtype=subfeed_dtype) File "/home/pi/.local/lib/python3.5/site-packages/numpy/core/numeric.py", line 538, in asarray return array(a, dtype, copy=False, order=order) TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType' VIDIOC_REQBUFS: No such device

The error is every time something _REQBUFS, I fond out if I lower the image sizer I can get this working very well but the problem is with an image size 150x150 I can not see nothing and all the fun is lost.

with a size 200x200 or high I got the error No such device
with a size 150x150 or low everything work great.

Why????
Any idea???
Its just me???
Can I solve it???

Thanks

Movidius NCS

I have tested a similar code( Tensorflow SSD model on my raspberry pi with dlib tracker) on my raspberry pi and it works fine but it is still slow. so I decide to use NCS movidius... Have you tried it? where should I start?

Tip about custom object training

I initially had several problems when running the rasp models, because in TF 1.1 it was possible to run in rasp, but the models were large and always exceeded memory, with its tutorial and the new tflite models I finally got.

My tip is: when exporting the graph, do it in rasp, because I tried to export the graph on the pc I trained and when I load it in rasp I get the following error: graph._c_graph, serialized, options) # pylint: disable = protected-access
tensorflow.python.framework.errors_impl.NotFoundError: Op type not registered 'NonMaxSuppressionV3' in binary running on raspberrypi. Make sure the Op and Kernel are registered in the binary running in this process.

Headless rpi B+

Hi all.

Follow all the tuts and some workaround.
Able to complete all tutorial with less error.
But when i issue

sudo pyhton3 object_detectionetcetc.py

I got this error
"cannot connect to X server"

Any work around on this?
Been struggling for 3 days with this.

Setup :
Pi camera
Rpi b+
My living room samsung tv via hdmi to rpi (headless)

Did test take picture manually is ok
Did test take video manually is ok
Did test with keyboard usb with hdmi tv screen upon booth up

So far i m only SSH to rpi b+ via laptop(windows) & ssh via android phone.

File "/home/pi/.local/lib/python3.5/site-packages/cv2/__init__.py", line 3, in <module> error

This is my 2nd SD card having different error..
The 1st had a different error

pi@raspberrypi:~/tensorflow1/models/research/object_detection $ python3 Object_detection_picamera.py
Traceback (most recent call last):
  File "Object_detection_picamera.py", line 23, in <module>
    import cv2
  File "/home/pi/.local/lib/python3.5/site-packages/cv2/__init__.py", line 3, in <module>
    from .cv2 import *
ImportError: libcblas.so.3: cannot open shared object file: No such file or directory

Allocation of 2764800 exceeds 10% of system memory - error. any help?

pi@raspberrypi:~/tensorflow1/models/research/object_detection $ python3 Object_detection_picamera.py --usbcam
2019-02-01 01:25:45.681330: W tensorflow/core/framework/allocator.cc:122] Allocation of 2764800 exceeds 10% of system memory.
2019-02-01 01:25:47.063722: W tensorflow/core/framework/allocator.cc:122] Allocation of 2795520 exceeds 10% of system memory.
2019-02-01 01:25:48.364439: W tensorflow/core/framework/allocator.cc:122] Allocation of 2795520 exceeds 10% of system memory.
2019-02-01 01:25:49.651463: W tensorflow/core/framework/allocator.cc:122] Allocation of 2795520 exceeds 10% of system memory.
2019-02-01 01:25:51.249713: W tensorflow/core/framework/allocator.cc:122] Allocation of 2795520 exceeds 10% of system memory.
: cannot connect to X server

Raspberry Pi hangs and reboots!

I did everything as per you said and everything worked fine, everything was exactly the same as you did! But when i execute the last instruction for opening the camera and identify the objects the pi just hangs and reboots. I also made sure that nothing except the terminal was working. Please help!

Tensorflow Object Detection on the Raspberry Zero?

hi
i have the same Problem with my Pi zero, When i write the command "python3 Object_detection_picamera.py" i became follow error:
"illegal Instruction"

i tested on my Pi 3 and it works fine!

please how can i fix it... i need that for my project at the university.

screenshot 2019-01-15 at 02 00 53

thanks

Image/Pictures as Source

Great tutorial this far. My only mistake, not reading to the end before.
Instead of using a camera as source, I wanted to provide existing images as input, resulting in a copy with drawn rectangles where recognition successed.

Is this possible with the given code? In my level of understanding, the basic functionality should be the same. For a camera as input, there only is a wrapper that extract singles images and calls a function?! Or is it done by video stream as input?

Raspberry hangs

Based on I trained a model to detect 3 labels. I have exported the model and transferred it to Raspberry pi as per . However, when I run the new model the raspberry pi hangs.

Please note:
New model has a frozen inference graph of 48MB and was trained on Faster-RCNN-Inception-V2 model.
Kindly advise best way forward to enable the model to run as expected.
Thanks

IMPROVEMENT: cut down build times

IMPROVEMENT:

Depending on which RPi the instructions are being executed on, it's possible to cut down the build time by using

make -j4
make check -j4

instead of

make
make check

On my RPi 3B+, "make check -j4" took only 50 minutes as opposed to 107 minutes as mentioned in the instructions.

HTH

showing the video, but not recognize the result and bbox.

test this:Tutorial to set up TensorFlow Object Detection API on the Raspberry Pi

I ran the program successfully, showing the video, but I did not recognize the result and bbox.
and test simple code:
import tensorflow as tf
happy= tf.constant('Happy new year!')
sess = tf.Session()
sess.run(happy)

tensorflow works well

Slower inference time on modified models

I trained 2 different models on top of the ssdlite_mobilenet_v2_coco from the tensorflow object api model zoo, but I get different speeds on each model when running on the Raspberry Pi 3:

ssdlite_mobilenet_v2_coco (90 classes) = 1.3 fps
retrained_ssdlite_1 (2 classes) = 0.7 fps
retrained_ssdlite_2 (3 classes) = 0.8 fps

My trained models are experimenting an drop of almost half the speed of the original model

Is anybody having the same issue?
Am I missing some step to make the model efficient at inference time?

"pip3 install opencv-python" is failed

It's strange.
The "pip3 install opencv-python" command generates a error message as following:

pi@raspberrypi:~ $
pi@raspberrypi:~ $ pip3 install opencv-python
Traceback (most recent call last):
  File "/usr/bin/pip3", line 9, in <module>
    from pip import main
ImportError: cannot import name 'main'
pi@raspberrypi:~ $
  • System environment
pi@raspberrypi:~ $ cat /etc/debian_version
9.8
pi@raspberrypi:~ $ cat /etc/*release*
PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)"
NAME="Raspbian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"
pi@raspberrypi:~ $

Step 5 git checkout v1.8.0 command

When this command is entered while in /tensorflow1/models/ it deletes all previous downloaded files in models/research with exception of syntaxnet. I think this isnt the desired effect? Right? If I am correct, how what would I be doing wrong thus the result. I choose to ignore the message, wise choice? Thanks

libraries libxml2 and libxslt not found during "make"

tried doing the Tensorflow from both MagiPi web site and from GitHub. In both cases, during the "make" steps for tensorflow I would get error messages saying the libraries libxml2 and libxslt could not be found.

I did a dpkg get-selection and found these files were known to my packages. However, whenever I tried to build a sample file that needed either of them, gcc would give an error that these files were not found.

I then went to www.xml.org to get the sources to these files (they are not loaded by sudo apt-get install at all). Here is how to compile them:
http://xmlsoft.org/FAQ.html

Take the latest and greatest of libxml2 and libxslt found in their resources and then use the ./configure and make and make install to get them into your RaspberryPi system. Once those two libraries were build and installed, then everything else in the GitHub process worked.
tjcooper

Object Counting Orientation

How would you run a variation of the model to count objects moving down a surface? Fairly new to object detection.

Adding more functionality

I would like to edit the code to

  1. (Scenario 1) print results on terminal when a certain object with a associated percentage is detected, say a pen at 70%+ then (predetermined) message is printed on terminal or
  2. (Scenario 2) detect/inference on (use) images taken at timed intervals instead of video

ImportError: libImath-2_2.so.12: cannot open shared object file: No such file or directory

Heya
I'm trying to run the command "python3 Object_detection_picamera.py " and I keep getting the this stack being returned:

Traceback (most recent call last):
  File "Object_detection_picamera.py", line 23, in <module>
    import cv2
  File "/home/pi/.local/lib/python3.5/site-packages/cv2/__init__.py", line 3, in <module>
    from .cv2 import *
ImportError: libImath-2_2.so.12: cannot open shared object file: No such file or directory

I have followed all the instructions and just wondering what is the problem - have I missed something or is there something else that I need to install?

Thank you

Osian

File "Object_detection_picamera.py", line 137, in <module> error

pi@raspberrypi:~/tensorflow1/models/research/object_detection $ python3 Object_detection_picamera.py
Traceback (most recent call last):
  File "Object_detection_picamera.py", line 137, in <module>
    frame.setflags(write=1)
ValueError: cannot set WRITEABLE flag to True of this array

TF Lite compatibility

Thank you for the tutorial. I'll preface this by saying that I'm a complete novice with TensorFlow/object detection, so apologies if what I'm saying doesn't make sense.

Is there a way to easily adapt this code to make it work with TensorFlow Lite?

I've gotten it to work with normal TensorFlow and the ssdlite_mobilenet_coco_v2 model. On hand I have the converted .tflite file for the .pb file in the ssd_mobilenet_v2_quantized_300x300_coco model. Any help would be greatly appreciated.

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.