Jetson Nano-Install and deploy PaddleHub lightweight code to achieve target detection

Software Environment

  • Ubuntu 18.04
  • JetPack 4.4 (Be sure to choose 4.4 here, test 4.3 install paddlepaddle-gpu error report)

If you haven’t configured Jetson Nano, you can refer to this blog to configure: Jetson Nano-JUBUB 18.04 basic configuration (replacement, remote desktop, fan, etc.)

Install paddleHub

(1) python3 install and update pip and change the source

Jetson Nano-install pip and change source

(2) Install PaddlePaddle

1. Download the official compiled whl

Select the download of python3.6 version.
Insert picture description here

2. Install whl

Transfer the downloaded whl file to nano, and then install whl:

pip3 install paddlepaddle_gpu-2.0.0-cp36-cp36m-linux_aarch64.whl

Screenshot of successful installation:
Insert picture description here

3. Test

Open python3:

import paddle
paddle.fluid.install_check.run_check()

Just report the warning and ignore it, and it will not affect the use.
Insert picture description here

(3) Install PaddleHub

1. Compile nccl
git clone https://github.com/NVIDIA/nccl.git   
cd nccl     
make -j4     
sudo make install 
2. Source code compilation sentencepiece

Compilation environment installation:

sudo apt-get install cmake build-essential pkg-config libgoogle-perftools-dev

Download the source package sentencepiece-master.zip:

https://github.com/google/sentencepiece

Then compile the source code:

unzip sentencepiece-master.zip
cd sentencepiece-master
mkdir build
cd build
cmake ..
make -j4
sudo make install
sudo ldconfig -v
3. Install paddlehub
  • 1.8.0 version (fast installation and stable )
sudo apt-get install python3-matplotlib
pip3 install paddlehub==1.8.0 # 1.8版本安装较快
  • Version 2.0.0 (currently it will crash in actual measurement, it is not recommended)
    Insert picture description here
sudo apt-get install python3-matplotlib python3-h5py
pip3 install seqeval # 此步可能会安装较多依赖项,需要耐心等待
pip3 install paddlehub
4. Test

Python test after successful installation: import paddlehub.

Insert picture description here

Run the target detection model

Here I choose pyramidbox_face_detection face detection model .

If you use paddlehub 1.8, you need to download the 1.0 version of the model first, because directly using the 1.1 version of the model will report an error:

hub install pyramidbox_face_detection==1.0.0

Detection code

import paddlehub as hub
import cv2
import time

if __name__ == "__main__":
    input_dict = {
    
    "image": ['./test.jpg']}
    face_detector = hub.Module(name="pyramidbox_face_detection")
    result = face_detector.face_detection(data=input_dict)

    print("result", result)
    cv2.waitKey()

AssertionError error resolution

Insert picture description here

Solution: Just add it to the previous line /home/nano/.local/lib/python3.6/site-packages/paddlehub/module/module.pyof the load_inference_model()function in the file paddle.enable_static().
Insert picture description here

operation result

Insert picture description here

Reference article:

Guess you like

Origin blog.csdn.net/qq_45779334/article/details/114436858