Segmentation Fault Tensorflow Lite

Viewed 1472

Hi I got the following error: "Segmentation fault" on my Raspberry Pi 4 Model B. I am following David Tian's Guide to build a Smart Robot Car which uses Deep Learning.

Some important informations:

  • Raspberry Pi 4 Model B
  • Raspbian Buster
  • Python3 3.7.3
  • (Pip3 20.0.2)
  • TensorFlow 2.0.0
  • Keras 2.3.1
  • OpenCV 4.1.0
  • (ROS melodic)

At first I tried to install TensorFlow for the EdgeTPU like this:

wget https://dl.google.com/coral/edgetpu_api/edgetpu_api_latest.tar.gz -O edgetpu_api.tar.gz --trust-server-names
tar xzf edgetpu_api.tar.gz
cd edgetpu_api/
bash ./install.sh -y
sudo reboot now

Well that`s not working on the new Raspberry Pi 4, so I followed this instruction

echo "deb https://packages.cloud.google.com/apt coral-edgetpu-stable main" | sudo tee /etc/apt/sources.list.d/coral-edgetpu.list
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
sudo apt-get update
sudo apt-get install libedgetpu1-std
pip3 install https://dl.google.com/coral/python/tflite_runtime-2.1.0.post1-cp37-cp37m-linux_armv7l.whl
sudo apt-get install libedgetpu1-max
mkdir coral && cd coral
git clone https://github.com/google-coral/tflite.git
cd tflite/python/examples/classification
bash install_requirements.sh
python3 classify_image.py \
--model models/mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite \
--labels models/inat_bird_labels.txt \
--input images/parrot.jpg

Well this isn`t my problem. This example works fine.

Back to Tian's Guide, I tried following

cd ~/DeepPiCar/models/object_detection/
python3 code/coco_object_detection.py
Segmentation fault

You can look at this code here

I'm not sure if it is an configuration or an installation or a problem within this code. I think the segmentation fault occurs because of the Coral Edge TPU.

I also tried

sudo apt-get update
sudo apt-get install python3-edgetpu

What else should I do? Can anyone help? Thanks in advance.

1 Answers

I have the same issue on a Pi 3B -- the trace output I get is as follows:

--- modulename: coco_object_detection, funcname: 
coco_object_detection.py(28): labels = dict((int(k), v) for k, v in pairs)
--- modulename: coco_object_detection, funcname: 
coco_object_detection.py(27): pairs = (l.strip().split(maxsplit=1) for l in f.readlines())
coco_object_detection.py(31): IM_WIDTH = 640
coco_object_detection.py(32): IM_HEIGHT = 480
coco_object_detection.py(33): camera = cv2.VideoCapture(0)
coco_object_detection.py(34): ret = camera.set(3,IM_WIDTH)
coco_object_detection.py(35): ret = camera.set(4,IM_HEIGHT)
coco_object_detection.py(37): font = cv2.FONT_HERSHEY_SIMPLEX
coco_object_detection.py(38): bottomLeftCornerOfText = (10,IM_HEIGHT-10)
coco_object_detection.py(39): fontScale = 1
coco_object_detection.py(40): fontColor = (255,255,255) # white
coco_object_detection.py(41): boxColor = (0,0,255) # RED?
coco_object_detection.py(42): boxLineWidth = 1
coco_object_detection.py(43): lineType = 2
coco_object_detection.py(45): annotate_text = ""
coco_object_detection.py(46): annotate_text_time = time.time()
coco_object_detection.py(47): time_to_show_prediction = 1.0 # ms
coco_object_detection.py(48): min_confidence = 0.20
coco_object_detection.py(51): engine = edgetpu.detection.engine.DetectionEngine(args.model)
--- modulename: engine, funcname: init
engine.py(69): if device_path:
engine.py(72): super().init(model_path)
--- modulename: basic_engine, funcname: init
basic_engine.py(36): if device_path:
basic_engine.py(40): self._engine = BasicEnginePythonWrapper.CreateFromFile(model_path)
free(): invalid pointer
Aborted
Related