Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 14 additions & 24 deletions .ci_local_test/ros2_openvino_toolkit_test/docker_run.sh
Original file line number Diff line number Diff line change
@@ -1,43 +1,33 @@
#!/bin/bash

export DISPLAY=:0

export work_dir=$PWD


function run_container() {

docker images | grep ros2_openvino_docker

if [ $? -eq 0 ]
then
echo "the image of ros2_openvino_docker:01 existence"
function run_container()
{
if docker images -q ros2_openvino_docker:01 &>/dev/null; then
echo "The container ros2_openvino_docker:01 image exists"
docker rmi -f ros2_openvino_docker:01
fi

docker ps -a | grep ros2_openvino_container
if [ $? -eq 0 ]
then
if docker ps -aq -f name=ros2_openvino_container; then
echo "The container ros2_openvino_container exists. Removing the container..."
docker rm -f ros2_openvino_container
fi

# Removing some docker image ..
# Using jenkins server ros2_openvino_toolkit code instead of git clone code.
cd $work_dir && sed -i '/RUN git clone -b ros2/d' Dockerfile
cd "$work_dir" && sed -i '/RUN git clone -b ros2/d' Dockerfile
# add the jpg for test.
cd $work_dir && sed -i '$i COPY jpg /root/jpg' Dockerfile

cd $work_dir && docker build --build-arg ROS_PRE_INSTALLED_PKG=galactic-desktop --build-arg VERSION=galactic -t ros2_openvino_docker:01 .
cd $work_dir && docker images
docker run -i --privileged=true --device=/dev/dri -v $work_dir/ros2_openvino_toolkit:/root/catkin_ws/src/ros2_openvino_toolkit -v $HOME/.Xauthority:/root/.Xauthority -e GDK_SCALE -v $work_dir/test_cases:/root/test_cases --name ros2_openvino_container ros2_openvino_docker:01 bash -c "cd /root/test_cases && ./run.sh galactic"
cd "$work_dir" && sed -i '$i COPY jpg /root/jpg' Dockerfile

cd "$work_dir" && docker build --build-arg ROS_PRE_INSTALLED_PKG=galactic-desktop --build-arg VERSION=galactic -t ros2_openvino_docker:01 .
cd "$work_dir" && docker images
docker run -i --privileged=true --device=/dev/dri -v "$work_dir"/ros2_openvino_toolkit:/root/catkin_ws/src/ros2_openvino_toolkit -v "$HOME"/.Xauthority:/root/.Xauthority -e GDK_SCALE -v "$work_dir"/test_cases:/root/test_cases --name ros2_openvino_container ros2_openvino_docker:01 bash -c "cd /root/test_cases && ./run.sh galactic"
}

run_container
if [ $? -ne 0 ]
then
echo "Test fail"
exit -1
if ! run_container; then
echo "Test failed"
exit 1
fi


Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@
mkdir -p /opt/openvino_toolkit/models
#apt install -y python-pip
apt install -y python3.8-venv
cd ~ && python3 -m venv openvino_env && source openvino_env/bin/activate
cd ~ && python3 -m venv openvino_env
#shellcheck source=/dev/null
source openvino_env/bin/activate
python -m pip install --upgrade pip
pip install openvino-dev[tensorflow2,onnx]==2022.3

pip install "openvino-dev[tensorflow2,onnx]==2022.3"

#Download the optimized Intermediate Representation (IR) of model (execute once)
cd ~/catkin_ws/src/ros2_openvino_toolkit/data/model_list && omz_downloader --list download_model.lst -o /opt/openvino_toolkit/models/

cd ~/catkin_ws/src/ros2_openvino_toolkit/data/model_list && omz_converter --list convert_model.lst -d /opt/openvino_toolkit/models/ -o /opt/openvino_toolkit/models/convert


#Copy label files (execute once)
cp ~/catkin_ws/src/ros2_openvino_toolkit/data/labels/face_detection/face-detection-adas-0001.labels /opt/openvino_toolkit/models/intel/face-detection-adas-0001/FP32/
cp ~/catkin_ws/src/ros2_openvino_toolkit/data/labels/face_detection/face-detection-adas-0001.labels /opt/openvino_toolkit/models/intel/face-detection-adas-0001/FP16/
Expand All @@ -27,4 +26,3 @@ cp /opt/openvino_toolkit/models/convert/public/mask_rcnn_inception_resnet_v2_atr

cd /root/test_cases/ && ./yolov5_model_download.sh
cd /root/test_cases/ && ./yolov8_model_download.sh

9 changes: 5 additions & 4 deletions .ci_local_test/ros2_openvino_toolkit_test/test_cases/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ then
else
export ros2_branch=$1
fi
source /root/test_cases/config.sh $ros2_branch
#shellcheck source=/dev/null
source /root/test_cases/config.sh "$ros2_branch"

cd /root/catkin_ws && colcon build --symlink-install
cd /root/catkin_ws && source ./install/local_setup.bash
# shellcheck source=/dev/null
source ./install/local_setup.bash

apt-get update
# apt-get install -y ros-$ros2_branch-diagnostic-updater
Expand All @@ -31,6 +33,5 @@ result=$?
echo "Test ENV:" && df -h && free -g
if [ $result -ne 0 ]
then
exit -1
exit 1
fi

Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,32 @@ cd /root && git clone https://github.com/ultralytics/yolov5.git

#Set Environment for Installing YOLOv5

cd yolov5
cd yolov5 || exit
python3 -m venv yolo_env # Create a virtual python environment
# shellcheck source=/dev/null
source yolo_env/bin/activate # Activate environment
pip install -r requirements.txt # Install yolov5 prerequisites
pip install wheel
pip install onnx

# Download PyTorch Weights
mkdir -p /root/yolov5/model_convert && cd /root/yolov5/model_convert
mkdir -p /root/yolov5/model_convert && cd /root/yolov5/model_convert || exit
wget https://github.com/ultralytics/yolov5/releases/download/v6.2/yolov5n.pt

cd /root/yolov5
cd /root/yolov5 || exit
python3 export.py --weights model_convert/yolov5n.pt --include onnx


#2. Convert ONNX files to IR files
cd /root/yolov5/
cd /root/yolov5/ || exit
python3 -m venv ov_env # Create openVINO virtual environment
# shellcheck source=/dev/null
source ov_env/bin/activate # Activate environment
python -m pip install --upgrade pip # Upgrade pip
pip install openvino[onnx]==2022.3.0 # Install OpenVINO for ONNX
pip install openvino-dev[onnx]==2022.3.0 # Install OpenVINO Dev Tool for ONNX

pip install "openvino[onnx]==2022.3.0" # Install OpenVINO for ONNX
pip install "openvino-dev[onnx]==2022.3.0" # Install OpenVINO Dev Tool for ONNX

cd /root/yolov5/model_convert
cd /root/yolov5/model_convert || exit
mo --input_model yolov5n.onnx


mkdir -p /opt/openvino_toolkit/models/convert/public/yolov5n/FP32/
sudo cp yolov5n.bin yolov5n.mapping yolov5n.xml /opt/openvino_toolkit/models/convert/public/yolov5n/FP32/

Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,21 @@

#Pip install the ultralytics package including all requirements in a Python>=3.7 environment with PyTorch>=1.7.

mkdir -p yolov8 && cd yolov8
mkdir -p yolov8 && cd yolov8 || exit
pip install ultralytics
apt install python3.8-venv
python3 -m venv openvino_env
# shellcheck source=/dev/null
source openvino_env/bin/activate


#Export a YOLOv8n model to a different format like ONNX, CoreML, etc.
# export official model
yolo export model=yolov8n.pt format=openvino
yolo export model=yolov8n-seg.pt format=openvino


# Move to the Recommended Model Path
mkdir -p /opt/openvino_toolkit/models/convert/public/FP32/yolov8n
mkdir -p /opt/openvino_toolkit/models/convert/public/FP32/yolov8n-seg

cp yolov8n_openvino_model/* /opt/openvino_toolkit/models/convert/public/FP32/yolov8n
cp yolov8n-seg_openvino_model/* /opt/openvino_toolkit/models/convert/public/FP32/yolov8n-seg

Loading