google-coral / project-posenet

Human Pose Detection on EdgeTPU
Apache License 2.0
550 stars 155 forks source link

Segmentation fault when running on RASPI4 w/ Coral #43

Open iCUE-Solutions opened 3 years ago

iCUE-Solutions commented 3 years ago

Is this example supposed to also run on RASPI 4 or am I just wasting my time?

Independent of the model used I get this error.

Loading model: models/mobilenet/posenet_mobilenet_v1_075_481_641_quant_decoder_edgetpu.tflite [1] 18593 segmentation fault python3 anonymizer.py

Namburger commented 3 years ago

Hello, this should works on the pi4, however we recently deprecated the edgetpu API and is actively workiong on a fix. For now, please use my fork: https://github.com/Namburger/project-posenet More details here: https://github.com/google-coral/project-posenet/issues/42#issuecomment-738026058

andrewtvuong commented 3 years ago

I have this same problem

➜ project-posenet git:(master) python3 pose_camera.py --res 480x360 /home/pi/workspace/project-posenet/gstreamer.py:15: PyGIWarning: Gst was imported without specifying a version first. Use gi.require_version('Gst', '1.0') before import to ensure that the right version gets loaded. from gi.repository import GLib, GObject, Gst, GstBase, GstVideo, Gtk /home/pi/workspace/project-posenet/gstreamer.py:15: PyGIWarning: GstBase was imported without specifying a version first. Use gi.require_version('GstBase', '1.0') before import to ensure that the right version gets loaded. from gi.repository import GLib, GObject, Gst, GstBase, GstVideo, Gtk /home/pi/workspace/project-posenet/gstreamer.py:15: PyGIWarning: GstVideo was imported without specifying a version first. Use gi.require_version('GstVideo', '1.0') before import to ensure that the right version gets loaded. from gi.repository import GLib, GObject, Gst, GstBase, GstVideo, Gtk Unable to init server: Could not connect: Connection refused Unable to init server: Could not connect: Connection refused /home/pi/workspace/project-posenet/gstreamer.py:15: PyGIWarning: Gtk was imported without specifying a version first. Use gi.require_version('Gtk', '3.0') before import to ensure that the right version gets loaded. from gi.repository import GLib, GObject, Gst, GstBase, GstVideo, Gtk Loading model: models/mobilenet/posenet_mobilenet_v1_075_353_481_quant_decoder_edgetpu.tflite Gstreamer pipeline: v4l2src device=/dev/video0 ! video/x-raw,width=640,height=480,framerate=30/1 ! decodebin ! videoflip video-direction=identity ! tee name=t t. ! queue max-size-buffers=1 leaky=downstream ! videoconvert ! freezer name=freezer ! rsvgoverlay name=overlay ! videoconvert ! autovideosink t. ! queue max-size-buffers=1 leaky=downstream ! videoconvert ! videoscale ! video/x-raw,width=470,height=353 ! videobox name=box autocrop=true ! video/x-raw,format=RGB,width=481,height=353 ! appsink name=appsink emit-signals=true max-buffers=1 drop=true

[1] 17780 segmentation fault python3 pose_camera.py --res 480x360

Does this mean the fix is not ready? @Namburger

hjonnala commented 3 years ago

@andrewtvuong I am able to run this command python3 pose_camera.py --res 480x360 on RASPI4 without any error.

I don't see these lines on cmd:

Unable to init server: Could not connect: Connection refused
Unable to init server: Could not connect: Connection refused
andrewtvuong commented 3 years ago

Unable to init server: Could not connect: Connection refused Unable to init server: Could not connect: Connection refused

@hjonnala I'm thinking this is due to me running the setup as headless. At the same time, I am also seeing seg fault as @iCUE-Solutions and some other folks in related issues https://github.com/google-coral/project-posenet/issues/42#issuecomment-738026058

hjonnala commented 3 years ago

can you share output of following command:

python3 -c 'from pycoral.utils.edgetpu import get_runtime_version; print(get_runtime_version())'

andrewtvuong commented 3 years ago

python3 -c 'from pycoral.utils.edgetpu import get_runtime_version; print(get_runtime_version())' produces BuildLabel(COMPILER=6.3.0 20170516,DATE=redacted,TIME=redacted), RuntimeVersion(14)

hjonnala commented 3 years ago

can you try python3 simple_pose.py and see if you are getting any segmentation fault?

andrewtvuong commented 3 years ago

Thanks python3 simple_pose.py works well python3 anonymizer.py

/home/pi/workspace/project-posenet/gstreamer.py:15: PyGIWarning: Gst was imported without specifying a version first. Use gi.require_version('Gst', '1.0') before import to ensure that the right version gets loaded. from gi.repository import GLib, GObject, Gst, GstBase, GstVideo, Gtk /home/pi/workspace/project-posenet/gstreamer.py:15: PyGIWarning: GstBase was imported without specifying a version first. Use gi.require_version('GstBase', '1.0') before import to ensure that the right version gets loaded. from gi.repository import GLib, GObject, Gst, GstBase, GstVideo, Gtk /home/pi/workspace/project-posenet/gstreamer.py:15: PyGIWarning: GstVideo was imported without specifying a version first. Use gi.require_version('GstVideo', '1.0') before import to ensure that the right version gets loaded. from gi.repository import GLib, GObject, Gst, GstBase, GstVideo, Gtk Unable to init server: Could not connect: Connection refused Unable to init server: Could not connect: Connection refused /home/pi/workspace/project-posenet/gstreamer.py:15: PyGIWarning: Gtk was imported without specifying a version first. Use gi.require_version('Gtk', '3.0') before import to ensure that the right version gets loaded. from gi.repository import GLib, GObject, Gst, GstBase, GstVideo, Gtk Loading model: models/mobilenet/posenet_mobilenet_v1_075_481_641_quant_decoder_edgetpu.tflite Gstreamer pipeline: v4l2src device=/dev/video0 ! video/x-raw,width=640,height=480,framerate=30/1 ! decodebin ! videoflip video-direction=identity ! tee name=t t. ! queue max-size-buffers=1 leaky=downstream ! videoconvert ! freezer name=freezer ! rsvgoverlay name=overlay ! videoconvert ! autovideosink t. ! queue max-size-buffers=1 leaky=downstream ! videoconvert ! videoscale ! video/x-raw,width=641,height=480 ! videobox name=box autocrop=true ! video/x-raw,format=RGB,width=641,height=481 ! appsink name=appsink emit-signals=true max-buffers=1 drop=true

[1] 1325 segmentation fault python3 anonymizer.py

python3 posenet_engine_test.py

FAIL: test_model_accuracy (main.PoseEngineAccuracyTest) x---------------------------------------------------------------------- Traceback (most recent call last): File "posenet_engine_test.py", line 52, in test_model_accuracy model_keypoint.point[0], reference_keypoint.point[0], delta=pixel_delta) AssertionError: 544.0 != 536.91327 within 4.0 delta (7.086729999999989 difference)

x---------------------------------------------------------------------- Ran 1 test in 3.234s

FAILED (failures=1)

python3 test_utils.py

F driver/usb/usb_driver.cc:857] transfer on tag 2 failed. Abort. Deadline exceeded: USB transfer error 2 [LibUsbDataOutCallback] [1] 1552 abort python3 test_utils.py

EDIT: very weird, running python3 simple_pose.py after the above sequence now fails with following error:

Traceback (most recent call last): File "/usr/lib/python3/dist-packages/tflite_runtime/interpreter.py", line 160, in load_delegate delegate = Delegate(library, options) File "/usr/lib/python3/dist-packages/tflite_runtime/interpreter.py", line 119, in init raise ValueError(capture.message) ValueError

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "simple_pose.py", line 27, in 'models/mobilenet/posenet_mobilenet_v1_075_481_641_quant_decoder_edgetpu.tflite') File "/home/pi/workspace/project-posenet/pose_engine.py", line 79, in init edgetpu_delegate = load_delegate(EDGETPU_SHARED_LIB) File "/usr/lib/python3/dist-packages/tflite_runtime/interpreter.py", line 163, in load_delegate library, str(e))) ValueError: Failed to load delegate from libedgetpu.so.1

hjonnala commented 3 years ago

please check this: https://coral.ai/docs/notes/build-coral/#failed-to-load-delegate-from-libedgetpuso1 to resolve ValueError: Failed to load delegate from libedgetpu.so.1

hjonnala commented 3 years ago

I am not having any segmentation issue with any script. I have python 3.7.3.

what is your python version? tflite_runtime version? pycoral version?

andrewtvuong commented 3 years ago

Python 3.7.3 tflite-runtime 2.5.0.post1 pycoral 2.0.0

hjonnala commented 3 years ago

Hmm.. I have same config.. can you try without headless?

andrewtvuong commented 3 years ago

with monitor

python3 pose_camera.py /home/pi/workspace/project-posenet/gstreamer.py:15: PyGIWarning: Gst was imported without specifying a version first. Use gi.require_version('Gst', '1.0') before import to ensure that the right version gets loaded. from gi.repository import GLib, GObject, Gst, GstBase, GstVideo, Gtk /home/pi/workspace/project-posenet/gstreamer.py:15: PyGIWarning: GstBase was imported without specifying a version first. Use gi.require_version('GstBase', '1.0') before import to ensure that the right version gets loaded. from gi.repository import GLib, GObject, Gst, GstBase, GstVideo, Gtk /home/pi/workspace/project-posenet/gstreamer.py:15: PyGIWarning: GstVideo was imported without specifying a version first. Use gi.require_version('GstVideo', '1.0') before import to ensure that the right version gets loaded. from gi.repository import GLib, GObject, Gst, GstBase, GstVideo, Gtk Unable to init server: Could not connect: Connection refused Unable to init server: Could not connect: Connection refused /home/pi/workspace/project-posenet/gstreamer.py:15: PyGIWarning: Gtk was imported without specifying a version first. Use gi.require_version('Gtk', '3.0') before import to ensure that the right version gets loaded. from gi.repository import GLib, GObject, Gst, GstBase, GstVideo, Gtk Loading model: models/mobilenet/posenet_mobilenet_v1_075_481_641_quant_decoder_edgetpu.tflite Gstreamer pipeline: v4l2src device=/dev/video0 ! video/x-raw,width=640,height=480,framerate=30/1 ! decodebin ! videoflip video-direction=identity ! tee name=t t. ! queue max-size-buffers=1 leaky=downstream ! videoconvert ! freezer name=freezer ! rsvgoverlay name=overlay ! videoconvert ! autovideosink t. ! queue max-size-buffers=1 leaky=downstream ! videoconvert ! videoscale ! video/x-raw,width=641,height=480 ! videobox name=box autocrop=true ! video/x-raw,format=RGB,width=641,height=481 ! appsink name=appsink emit-signals=true max-buffers=1 drop=true

Error: gst-resource-error-quark: GStreamer encountered a general resource error. (1): gstkmssink.c(1530): gst_kms_sink_show_frame (): /GstPipeline:pipeline0/GstAutoVideoSink:autovideosink0/GstKMSSink:autovideosink0-actual-sink-kms: drmModeSetPlane failed: Permission denied (-13)