|
1 | 1 | # pytorch_ros
|
2 | 2 |
|
3 |
| -A Docker environment for both training network on PyTorch, and inference using ROS is [here](https://github.com/ActiveIntelligentSystemsLab/pytorch-enet-docker). |
4 |
| -This package is only tested on the virtual environment. |
| 3 | +## 1. Overview |
| 4 | + |
| 5 | +A ROS package to use [LibTorch](https://pytorch.org/cppdocs/), a PyTorch C++ API, for inference on a trained model. |
| 6 | + |
| 7 | +A Docker environment for running this package is [here](https://github.com/ActiveIntelligentSystemsLab/pytorch-enet-docker). |
| 8 | +This package is **only tested in the virtual environment**. |
| 9 | + |
| 10 | +## 2. Nodes |
| 11 | + |
| 12 | +### 2.1 `pytorch_seg_trav_path_node` |
| 13 | + |
| 14 | +#### **2.1.1 Subscribed topics** |
| 15 | + |
| 16 | +- `image` ([sensor_msgs/Image](http://docs.ros.org/melodic/api/sensor_msgs/html/msg/Image.html)) |
| 17 | + |
| 18 | + An input image |
| 19 | + |
| 20 | +#### **2.1.2 Published topics** |
| 21 | + |
| 22 | +- `label` ([sensor_msgs/Image](http://docs.ros.org/melodic/api/sensor_msgs/html/msg/Image.html)) |
| 23 | + |
| 24 | + Image that stores label indices of each pixel |
| 25 | + |
| 26 | +- `color_label` ([sensor_msgs/Image](http://docs.ros.org/melodic/api/sensor_msgs/html/msg/Image.html)) |
| 27 | + |
| 28 | + Image that stores color labels of each pixel (for visualization) |
| 29 | + |
| 30 | +- `prob` ([sensor_msgs/Image](http://docs.ros.org/melodic/api/sensor_msgs/html/msg/Image.html)) |
| 31 | + |
| 32 | + Image that stores *traversability* of each pixel |
| 33 | + |
| 34 | +- `start_point` ([geometry_msgs/PointStamped](http://docs.ros.org/en/melodic/api/geometry_msgs/html/msg/PointStamped.html)) |
| 35 | + |
| 36 | + Start point of the estimated path line |
| 37 | + |
| 38 | +- `end_point` ([geometry_msgs/PointStamped](http://docs.ros.org/en/melodic/api/geometry_msgs/html/msg/PointStamped.html)) |
| 39 | + |
| 40 | + End point of the estimated path line |
| 41 | + |
| 42 | +#### **2.1.3 Service** |
| 43 | + |
| 44 | +- `get_label_image` ([semantic_segmentation_srvs/GetLabelAndProbability](https://github.com/ActiveIntelligentSystemsLab/aisl_utils/blob/master/aisl_srvs/semantic_segmentation_srv/srv/GetLabelAndProbability.srv)) |
| 45 | + |
| 46 | + Return inference results (segmentation and traversability) for a given image. |
| 47 | + |
| 48 | +## 3. How to run the node |
| 49 | + |
| 50 | +``` |
| 51 | +roslaunch pytorch_enet_ros.launch image:=<image topic name> model_name:=<model name> |
| 52 | +``` |
| 53 | + |
| 54 | +## 4. Weight files |
| 55 | + |
| 56 | +The ROS nodes in this package use models saved as a serialized Torch Script file. |
| 57 | + |
| 58 | +At this moment, we don't provide a script to generate the weight files. |
| 59 | + |
| 60 | +Refer to [this page](https://pytorch.org/tutorials/advanced/cpp_export.html) to get the weight file. |
| 61 | + |
| 62 | +### CAUTION |
| 63 | +If the version of PyTorch that runs this ROS package and that you generate your weight file (serialized Torch Script) do not match, the ROS node may fail to import the weights. |
| 64 | + |
| 65 | +For example, if you use [our Docker environment](https://github.com/ActiveIntelligentSystemsLab/pytorch-enet-docker), the weights should be generated using PyTorch 1.5.0. |
| 66 | + |
| 67 | +## 5. Color map |
| 68 | + |
| 69 | +For visualization of semantic segmentation, we use a color map image. |
| 70 | + |
| 71 | +It is a 1xC PNG image file (C: The number of classes), where |
| 72 | +the color of class i is stored in the pixel at (1, i). |
0 commit comments