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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* [➤ Overview](#overview)
* [ROS2 Version Supported](#ros2-version-supported)
* [Inference Features Supported](#inference-features-supported)
* [➤ Prerequisite](#prerequisite-for-ros2-branch)
* [➤ Prerequisite](#prerequisite)
* [➤ Introduction](#introduction)
* [Design Architecture](#design-architecture)
* [Logic Flow](#logic-flow)
Expand Down Expand Up @@ -241,6 +241,7 @@ For the snapshot of demo results, refer to the following picture.
* OpenVINO api 2.0: Refer to the OpenVINO document for [OpenVINO_api_2.0](https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html) for latest api 2.0 transition guide.

# FAQ
* [How to get the IR file for yolov5?](./doc/quick_start/tutorial_for_yolov5_converted.md)
* [How to build OpenVINO by source?](https://github.com/openvinotoolkit/openvino/wiki#how-to-build)
* [How to build RealSense by source?](https://github.com/IntelRealSense/librealsense/blob/master/doc/installation.md)
* [What is the basic command of Docker CLI?](https://docs.docker.com/engine/reference/commandline/docker/)
Expand Down
80 changes: 80 additions & 0 deletions data/labels/object_detection/coco.names
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
person
bicycle
car
motorbike
aeroplane
bus
train
truck
boat
traffic light
fire hydrant
stop sign
parking meter
bench
bird
cat
dog
horse
sheep
cow
elephant
bear
zebra
giraffe
backpack
umbrella
handbag
tie
suitcase
frisbee
skis
snowboard
sports ball
kite
baseball bat
baseball glove
skateboard
surfboard
tennis racket
bottle
wine glass
cup
fork
knife
spoon
bowl
banana
apple
sandwich
orange
broccoli
carrot
hot dog
pizza
donut
cake
chair
sofa
pottedplant
bed
diningtable
toilet
tvmonitor
laptop
mouse
remote
keyboard
cell phone
microwave
oven
toaster
sink
refrigerator
book
clock
vase
scissors
teddy bear
hair drier
toothbrush
88 changes: 88 additions & 0 deletions doc/quick_start/tutorial_for_yolov5_converted.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Tutorial_For_yolov5_Converted

# Introduction
This document describes a method to convert YOLOv5 nano PyTorch weight files with the. pt extension to ONNX weight files, and a method to convert ONNX weight files to IR files using the OpenVINO model optimizer. This method can help OpenVINO users optimize YOLOv5n for deployment in practical applications.

## Reference Phrase
|Term|Description|
|---|---|
|OpenVINO|Open Visual Inference & Neural Network Optimization|
|ONNX|Open Neural Network Exchange|
|YOLO|You Only Look Once|
|IR|Intermediate Representation|

## Reference Document
|Doc|Link|
|---|---|
|OpenVINO|[openvino_2_0_transition_guide](https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html)|
|YOLOv5|[yolov5](https://github.com/ultralytics/yolov5)|

# Convert Weight File to ONNX
* Copy YOLOv5 Repository from GitHub
```
git clone https://github.com/ultralytics/yolov5.git
```

* Set Environment for Installing YOLOv5
```
cd yolov5
python3 -m venv yolo_env // Create a virtual python environment
source yolo_env/bin/activate // Activate environment
pip install -r requirements.txt // Install yolov5 prerequisites
pip install onnx // Install ONNX
```

* Download PyTorch Weights
```
mkdir model_convert && cd model_convert
wget https://github.com/ultralytics/yolov5/releases/download/v6.2/yolov5n.pt
```

* Convert PyTorch weights to ONNX weights
YOLOv5 repository provides export.py script, which can be used to convert PyTorch weight to ONNX weight.
```
cd ..
python3 export.py --weights model_convert/yolov5n.pt --include onnx
```

# Convert ONNX files to IR files
After obtaining the ONNX weight file from the previous section [Convert Weight File to ONNX](#convert-weight-file-to-onnx), we can use the model optimizer to convert it to an IR file.

* Install the OpenVINO Model Optimizer Environment
To use the model optimizer, you need to run the following command to install some necessary components (if you are still in the yolo_env virtual environment, you need to run the **deactivate** command to exit the environment or start a new terminal).
```
python3 -m venv ov_env // Create openVINO virtual environment
source ov_env/bin/activate // Activate environment
python -m pip install --upgrade pip // Upgrade pip
pip install openvino[onnx]==2022.1.0 // Install OpenVINO for ONNX
pip install openvino-dev[onnx]==2022.1.0 // Install OpenVINO Dev Tool for ONNX
```

* Generate IR file
```
cd model_convert
mo --input_model yolov5n.onnx
```
Then we will get three files: yolov5n.xml, yolov5n.bin, and yolov5n.mapping under the model_convert folder.

# Move to the Recommended Model Path
```
cd ~/yolov5/model_convert
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/
```

# FAQ

<p>
<details>
<summary>How to install the python3-venv package?</summary>

On Debian/Ubuntu systems, you need to install the python3-venv package using the following command.
```
apt-get update
apt-get install python3-venv
```
You may need to use sudo with that command. After installing, recreate your virtual environment.
</details>
</p>
13 changes: 6 additions & 7 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ros2 openvino toolkit env master f1b1ca4d914186a1881b87f103be9c6e910c9d80

ARG ROS_VERSION
FROM osrf/ros:${ROS_VERSION}
ARG ROS_PRE_INSTALLED_PKG
FROM osrf/ros:${ROS_PRE_INSTALLED_PKG}
ARG VERSION

# setting proxy env --option
Expand All @@ -10,8 +10,10 @@ ARG VERSION
# ENV HTTPS_PROXY="your_proxy"
# ENV FTP_PROXY="your_proxy"

LABEL maintainer="Jiawei Wu <jiawei.wu@intel.com>"
# author information
LABEL author="Jiawei Wu <jiawei.wu@intel.com>"

# default shell type
SHELL ["/bin/bash", "-c"]

# ignore the warning
Expand Down Expand Up @@ -54,7 +56,6 @@ pyyaml \
requests \
&& apt-get install -y --no-install-recommends libboost-all-dev
WORKDIR /usr/lib/x86_64-linux-gnu
RUN ln -sf libboost_python-py36.so libboost_python37.so
RUN pip install --upgrade pip
RUN pip install openvino-dev[tensorflow2]==2022.1

Expand All @@ -63,9 +64,7 @@ WORKDIR /root
RUN mkdir -p catkin_ws/src
WORKDIR /root/catkin_ws/src
RUN git init && git clone https://github.com/intel/ros2_object_msgs.git \
&& git clone -b ros2 https://github.com/intel/ros2_openvino_toolkit.git \
&& git clone -b ${VERSION} https://github.com/ros-perception/vision_opencv.git \
&& git clone -b ros2-development https://github.com/IntelRealSense/realsense-ros.git
&& git clone -b ros2 https://github.com/intel/ros2_openvino_toolkit.git
RUN apt-get install ros-${VERSION}-diagnostic-updater
WORKDIR /root/catkin_ws
RUN source /opt/ros/${VERSION}/setup.bash && source /opt/intel/openvino_2022/setupvars.sh && colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release
Expand Down
6 changes: 3 additions & 3 deletions docker/docker_instructions_ov2.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ Refer to: [Docker_install_guide](https://docs.docker.com/engine/install/ubuntu/)
```
cd ~/ros2_openvino_toolkit/docker/Dockerfile
vi ~/ros2_openvino_toolkit/docker/Dockerfile
docker build --build-arg ROS_VERSION=<EXPECT_ROS_BASE_IMAGE> --build-arg VERSION=<EXPECT_ROS_VERSION> --build-arg "HTTP_PROXY=set_your_proxy" -t ros2_openvino_202201 .
docker build --build-arg ROS_PRE_INSTALLED_PKG=<EXPECT_ROS_PRE_INSTALLED_PKG> --build-arg VERSION=<EXPECT_ROS_VERSION> --build-arg "HTTP_PROXY=set_your_proxy" -t ros2_openvino_202201 .
```
For example:
* Build image for ros_galactic
```
cd ~/ros2_openvino_toolkit/docker/Dockerfile
vi ~/ros2_openvino_toolkit/docker/Dockerfile
docker build --build-arg ROS_VERSION=galactic-desktop --build-arg VERSION=galactic --build-arg "HTTP_PROXY=set_your_proxy" -t ros2_galactic_openvino_202201 .
docker build --build-arg ROS_PRE_INSTALLED_PKG=galactic-desktop --build-arg VERSION=galactic --build-arg "HTTP_PROXY=set_your_proxy" -t ros2_galactic_openvino_202201 .
```
* Build image for ros_foxy
```
cd ~/ros2_openvino_toolkit/docker/Dockerfile
vi ~/ros2_openvino_toolkit/docker/Dockerfile
docker build --build-arg ROS_VERSION=foxy-desktop --build-arg VERSION=foxy --build-arg "HTTP_PROXY=set_your_proxy" -t ros2_foxy_openvino_202201 .
docker build --build-arg ROS_PRE_INSTALLED_PKG=foxy-desktop --build-arg VERSION=foxy --build-arg "HTTP_PROXY=set_your_proxy" -t ros2_foxy_openvino_202201 .
```

## 3. Download and load docker image
Expand Down
4 changes: 2 additions & 2 deletions dynamic_vino_lib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2018-2020 Intel Corporation
# Copyright (c) 2018-2022 Intel Corporation

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -217,7 +217,7 @@ add_library(${PROJECT_NAME} SHARED
src/models/vehicle_attribs_detection_model.cpp
src/models/license_plate_detection_model.cpp
src/models/object_detection_ssd_model.cpp
src/models/object_detection_yolov2_model.cpp
src/models/object_detection_yolov5_model.cpp
src/outputs/image_window_output.cpp
src/outputs/ros_topic_output.cpp
src/outputs/rviz_output.cpp
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2018 Intel Corporation
// Copyright (c) 2018-2022 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2018-2019 Intel Corporation
// Copyright (c) 2018-2022 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2018 Intel Corporation
// Copyright (c) 2018-2022 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2018 Intel Corporation
// Copyright (c) 2018-2022 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2018 Intel Corporation
// Copyright (c) 2018-2022 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2018 Intel Corporation
// Copyright (c) 2018-2022 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2018 Intel Corporation
// Copyright (c) 2018-2022 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2018 Intel Corporation
// Copyright (c) 2018-2022 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2018 Intel Corporation
// Copyright (c) 2018-2022 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2018 Intel Corporation
// Copyright (c) 2018-2022 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2018 Intel Corporation
// Copyright (c) 2018-2022 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2018 Intel Corporation
// Copyright (c) 2018-2022 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2018 Intel Corporation
// Copyright (c) 2018-2022 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2018 Intel Corporation
// Copyright (c) 2018-2022 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2018 Intel Corporation
// Copyright (c) 2018-2022 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2018 Intel Corporation
// Copyright (c) 2022 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2018 Intel Corporation
// Copyright (c) 2018-2022 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2018 Intel Corporation
// Copyright (c) 2018-2022 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2018 Intel Corporation
// Copyright (c) 2018-2022 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2018 Intel Corporation
// Copyright (c) 2018-2022 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2018 Intel Corporation
// Copyright (c) 2018-2022 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2018 Intel Corporation
// Copyright (c) 2018-2022 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Loading