Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(tensorrt_yolox)!: fix namespace and directory structure #7992

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
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
control/autoware_pid_longitudinal_controller/** [email protected] [email protected] [email protected]
control/autoware_pure_pursuit/** [email protected] [email protected]
control/autoware_shift_decider/** [email protected] [email protected]
control/autoware_smart_mpc_trajectory_follower/** [email protected] [email protected] [email protected] [email protected]

Check warning on line 58 in .github/CODEOWNERS

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (aino)
control/autoware_trajectory_follower_base/** [email protected] [email protected]
control/autoware_trajectory_follower_node/** [email protected] [email protected]
control/autoware_vehicle_cmd_gate/** [email protected] [email protected]
Expand Down Expand Up @@ -135,7 +135,7 @@
perception/autoware_shape_estimation/** [email protected] [email protected]
perception/autoware_simple_object_merger/** [email protected] [email protected] [email protected]
perception/autoware_tensorrt_classifier/** [email protected] [email protected]
perception/tensorrt_yolox/** [email protected] [email protected]
perception/autoware_tensorrt_yolox/** [email protected] [email protected]
perception/traffic_light_arbiter/** [email protected] [email protected]
perception/autoware_traffic_light_classifier/** [email protected] [email protected] [email protected]
perception/autoware_traffic_light_fine_detector/** [email protected] [email protected] [email protected]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<arg name="output/rule_detector/objects"/>

<!-- Jetson AGX -->
<!-- <include file="$(find-pkg-share tensorrt_yolox)/launch/multiple_yolox.launch.xml">
<!-- <include file="$(find-pkg-share autoware_tensorrt_yolox)/launch/multiple_yolox.launch.xml">
<arg name="image_raw0" value="$(var input/camera0/image)"/>
<arg name="image_raw1" value="$(var input/camera1/image)"/>
<arg name="image_raw2" value="$(var input/camera2/image)"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.17)
project(tensorrt_yolox)
project(autoware_tensorrt_yolox)

find_package(tensorrt_common)
if(NOT ${tensorrt_common_FOUND})
Expand Down Expand Up @@ -138,7 +138,7 @@ target_compile_definitions(yolox_single_image_inference_node PRIVATE
)

rclcpp_components_register_node(yolox_single_image_inference_node
PLUGIN "tensorrt_yolox::YoloXSingleImageInferenceNode"
PLUGIN "autoware::tensorrt_yolox::YoloXSingleImageInferenceNode"
EXECUTABLE yolox_single_image_inference
)

Expand All @@ -159,7 +159,7 @@ target_compile_definitions(${PROJECT_NAME}_node PRIVATE
)

rclcpp_components_register_node(${PROJECT_NAME}_node
PLUGIN "tensorrt_yolox::TrtYoloXNode"
PLUGIN "autoware::tensorrt_yolox::TrtYoloXNode"
EXECUTABLE ${PROJECT_NAME}_node_exe
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# tensorrt_yolox
# autoware_tensorrt_yolox

## Purpose

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,33 @@
# cspell:ignore semseg
/**:
ros__parameters:

# refine segmentation mask by overlay roi class
# disable when sematic segmentation accuracy is good enough
is_roi_overlap_segment: true

# minimum existence_probability of detected roi considered to replace segmentation
overlap_roi_score_threshold: 0.3

# publish color mask for result visualization
is_publish_color_mask: false

roi_overlay_segment_label:
UNKNOWN : true
CAR : false
TRUCK : false
BUS : false
MOTORCYCLE : true
BICYCLE : true
PEDESTRIAN : true
ANIMAL: true

model_path: "$(var data_path)/tensorrt_yolox/$(var model_name).onnx" # The onnx file name for YOLOX model.
label_path: "$(var data_path)/tensorrt_yolox/label.txt" # The label file path for YOLOX model.
color_map_path: "$(var data_path)/tensorrt_yolox/semseg_color_map.csv"
score_threshold: 0.35 # Objects with a score lower than this value will be ignored. This threshold will be ignored if specified model contains EfficientNMS_TRT module in it.
nms_threshold: 0.7 # Detection results will be ignored if IoU over this value. This threshold will be ignored if specified model contains EfficientNMS_TRT module in it.

precision: "fp16" # Operation precision to be used on inference. Valid value is one of: [fp32, fp16, int8].
calibration_algorithm: "MinMax" # Calibration algorithm to be used for quantization when precision==int8. Valid value is one of: [Entropy, (Legacy | Percentile), MinMax].
dla_core_id: -1 # If positive ID value is specified, the node assign inference task to the DLA core.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
* DEALINGS IN THE SOFTWARE.
*/

#ifndef TENSORRT_YOLOX__CALIBRATOR_HPP_
#define TENSORRT_YOLOX__CALIBRATOR_HPP_
#ifndef AUTOWARE__TENSORRT_YOLOX__CALIBRATOR_HPP_
#define AUTOWARE__TENSORRT_YOLOX__CALIBRATOR_HPP_

#include "cuda_utils/cuda_check_error.hpp"
#include "cuda_utils/cuda_unique_ptr.hpp"
Expand All @@ -53,7 +53,7 @@
#include <string>
#include <vector>

namespace tensorrt_yolox
namespace autoware::tensorrt_yolox
{
class ImageStream
{
Expand Down Expand Up @@ -488,6 +488,6 @@ class Int8MinMaxCalibrator : public nvinfer1::IInt8MinMaxCalibrator
std::vector<char> hist_cache_;
double scale_;
};
} // namespace tensorrt_yolox
} // namespace autoware::tensorrt_yolox

#endif // TENSORRT_YOLOX__CALIBRATOR_HPP_
#endif // AUTOWARE__TENSORRT_YOLOX__CALIBRATOR_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef TENSORRT_YOLOX__PREPROCESS_HPP_
#define TENSORRT_YOLOX__PREPROCESS_HPP_
#ifndef AUTOWARE__TENSORRT_YOLOX__PREPROCESS_HPP_
#define AUTOWARE__TENSORRT_YOLOX__PREPROCESS_HPP_

#include <cublas_v2.h>
#include <cuda.h>
#include <cuda_runtime.h>
#include <cuda_runtime_api.h>
#include <curand.h>

namespace tensorrt_yolox
namespace autoware::tensorrt_yolox
{
struct Roi
{
Expand Down Expand Up @@ -195,5 +195,5 @@ extern void multi_scale_resize_bilinear_letterbox_nhwc_to_nchw32_batch_gpu(
extern void argmax_gpu(
unsigned char * dst, float * src, int d_w, int d_h, int s_w, int s_h, int s_c, int batch,
cudaStream_t stream);
} // namespace tensorrt_yolox
#endif // TENSORRT_YOLOX__PREPROCESS_HPP_
} // namespace autoware::tensorrt_yolox
#endif // AUTOWARE__TENSORRT_YOLOX__PREPROCESS_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef TENSORRT_YOLOX__TENSORRT_YOLOX_HPP_
#define TENSORRT_YOLOX__TENSORRT_YOLOX_HPP_
#ifndef AUTOWARE__TENSORRT_YOLOX__TENSORRT_YOLOX_HPP_
#define AUTOWARE__TENSORRT_YOLOX__TENSORRT_YOLOX_HPP_

#include <autoware/tensorrt_yolox/preprocess.hpp>
#include <cuda_utils/cuda_unique_ptr.hpp>
#include <cuda_utils/stream_unique_ptr.hpp>
#include <opencv2/opencv.hpp>
#include <tensorrt_common/tensorrt_common.hpp>
#include <tensorrt_yolox/preprocess.hpp>

#include <memory>
#include <string>
#include <vector>

namespace tensorrt_yolox
namespace autoware::tensorrt_yolox
{
using cuda_utils::CudaUniquePtr;
using cuda_utils::CudaUniquePtrHost;
Expand Down Expand Up @@ -312,6 +312,6 @@ class TrtYoloX
std::vector<tensorrt_yolox::Colormap> sematic_color_map_;
};

} // namespace tensorrt_yolox
} // namespace autoware::tensorrt_yolox

#endif // TENSORRT_YOLOX__TENSORRT_YOLOX_HPP_
#endif // AUTOWARE__TENSORRT_YOLOX__TENSORRT_YOLOX_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef TENSORRT_YOLOX__TENSORRT_YOLOX_NODE_HPP_
#define TENSORRT_YOLOX__TENSORRT_YOLOX_NODE_HPP_
#ifndef AUTOWARE__TENSORRT_YOLOX__TENSORRT_YOLOX_NODE_HPP_
#define AUTOWARE__TENSORRT_YOLOX__TENSORRT_YOLOX_NODE_HPP_

#include "object_recognition_utils/object_recognition_utils.hpp"

#include <autoware/tensorrt_yolox/tensorrt_yolox.hpp>
#include <autoware/universe_utils/ros/debug_publisher.hpp>
#include <autoware/universe_utils/system/stop_watch.hpp>
#include <image_transport/image_transport.hpp>
#include <opencv2/opencv.hpp>
#include <rclcpp/rclcpp.hpp>
#include <tensorrt_yolox/tensorrt_yolox.hpp>

#include <sensor_msgs/msg/image.hpp>
#include <std_msgs/msg/header.hpp>
Expand All @@ -42,7 +42,7 @@
#include <string>
#include <vector>

namespace tensorrt_yolox
namespace autoware::tensorrt_yolox
{
// cspell: ignore Semseg
using LabelMap = std::map<int, std::string>;
Expand Down Expand Up @@ -110,6 +110,6 @@ class TrtYoloXNode : public rclcpp::Node
std::unique_ptr<autoware::universe_utils::DebugPublisher> debug_publisher_;
};

} // namespace tensorrt_yolox
} // namespace autoware::tensorrt_yolox

#endif // TENSORRT_YOLOX__TENSORRT_YOLOX_NODE_HPP_
#endif // AUTOWARE__TENSORRT_YOLOX__TENSORRT_YOLOX_NODE_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -26,42 +26,42 @@
<arg name="image_number" default="1"/>
<arg name="output_topic" default="rois"/>

<include if="$(eval &quot;'$(var image_number)'>='1'&quot;)" file="$(find-pkg-share tensorrt_yolox)/launch/yolox.launch.xml">
<include if="$(eval &quot;'$(var image_number)'>='1'&quot;)" file="$(find-pkg-share autoware_tensorrt_yolox)/launch/yolox.launch.xml">
<arg name="input/image" value="$(var image_raw0)"/>
<arg name="output/objects" value="rois0"/>
<arg name="gpu_id" value="$(var gpu_id_image_raw0)"/>
</include>
<include if="$(eval &quot;'$(var image_number)'>='2'&quot;)" file="$(find-pkg-share tensorrt_yolox)/launch/yolox.launch.xml">
<include if="$(eval &quot;'$(var image_number)'>='2'&quot;)" file="$(find-pkg-share autoware_tensorrt_yolox)/launch/yolox.launch.xml">
<arg name="input/image" value="$(var image_raw1)"/>
<arg name="output/objects" value="rois1"/>
<arg name="gpu_id" value="$(var gpu_id_image_raw1)"/>
</include>
<include if="$(eval &quot;'$(var image_number)'>='3'&quot;)" file="$(find-pkg-share tensorrt_yolox)/launch/yolox.launch.xml">
<include if="$(eval &quot;'$(var image_number)'>='3'&quot;)" file="$(find-pkg-share autoware_tensorrt_yolox)/launch/yolox.launch.xml">
<arg name="input/image" value="$(var image_raw2)"/>
<arg name="output/objects" value="rois2"/>
<arg name="gpu_id" value="$(var gpu_id_image_raw2)"/>
</include>
<include if="$(eval &quot;'$(var image_number)'>='4'&quot;)" file="$(find-pkg-share tensorrt_yolox)/launch/yolox.launch.xml">
<include if="$(eval &quot;'$(var image_number)'>='4'&quot;)" file="$(find-pkg-share autoware_tensorrt_yolox)/launch/yolox.launch.xml">
<arg name="input/image" value="$(var image_raw3)"/>
<arg name="output/objects" value="rois3"/>
<arg name="gpu_id" value="$(var gpu_id_image_raw3)"/>
</include>
<include if="$(eval &quot;'$(var image_number)'>='5'&quot;)" file="$(find-pkg-share tensorrt_yolox)/launch/yolox.launch.xml">
<include if="$(eval &quot;'$(var image_number)'>='5'&quot;)" file="$(find-pkg-share autoware_tensorrt_yolox)/launch/yolox.launch.xml">
<arg name="input/image" value="$(var image_raw4)"/>
<arg name="output/objects" value="rois4"/>
<arg name="gpu_id" value="$(var gpu_id_image_raw4)"/>
</include>
<include if="$(eval &quot;'$(var image_number)'>='6'&quot;)" file="$(find-pkg-share tensorrt_yolox)/launch/yolox.launch.xml">
<include if="$(eval &quot;'$(var image_number)'>='6'&quot;)" file="$(find-pkg-share autoware_tensorrt_yolox)/launch/yolox.launch.xml">
<arg name="input/image" value="$(var image_raw5)"/>
<arg name="output/objects" value="rois5"/>
<arg name="gpu_id" value="$(var gpu_id_image_raw5)"/>
</include>
<include if="$(eval &quot;'$(var image_number)'>='7'&quot;)" file="$(find-pkg-share tensorrt_yolox)/launch/yolox.launch.xml">
<include if="$(eval &quot;'$(var image_number)'>='7'&quot;)" file="$(find-pkg-share autoware_tensorrt_yolox)/launch/yolox.launch.xml">
<arg name="input/image" value="$(var image_raw6)"/>
<arg name="output/objects" value="rois6"/>
<arg name="gpu_id" value="$(var gpu_id_image_raw6)"/>
</include>
<include if="$(eval &quot;'$(var image_number)'>='8'&quot;)" file="$(find-pkg-share tensorrt_yolox)/launch/yolox.launch.xml">
<include if="$(eval &quot;'$(var image_number)'>='8'&quot;)" file="$(find-pkg-share autoware_tensorrt_yolox)/launch/yolox.launch.xml">
<arg name="input/image" value="$(var image_raw7)"/>
<arg name="output/objects" value="rois7"/>
<arg name="gpu_id" value="$(var gpu_id_image_raw7)"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
description="options `yolox-sPlus-T4-960x960-pseudo-finetune` if only detection is needed, `yolox-sPlus-opt-pseudoV2-T4-960x960-T4-seg16cls` if sematic segmentation is also needed"
/>
<arg name="data_path" default="$(env HOME)/autoware_data" description="packages data and artifacts directory path"/>
<arg name="yolox_param_path" default="$(find-pkg-share tensorrt_yolox)/config/yolox_s_plus_opt.param.yaml"/>
<arg name="yolox_param_path" default="$(find-pkg-share autoware_tensorrt_yolox)/config/yolox_s_plus_opt.param.yaml"/>
<arg name="use_decompress" default="true" description="use image decompress"/>
<arg name="build_only" default="false" description="exit after trt engine is built"/>

Expand All @@ -21,7 +21,7 @@
<param from="$(var param_file)"/>
</node>

<node pkg="tensorrt_yolox" exec="tensorrt_yolox_node_exe" name="tensorrt_yolox" output="screen">
<node pkg="autoware_tensorrt_yolox" exec="autoware_tensorrt_yolox_node_exe" name="tensorrt_yolox" output="screen">
<remap from="~/in/image" to="$(var input/image)"/>
<remap from="~/out/objects" to="$(var output/objects)"/>
<remap from="~/out/mask" to="$(var output/mask)"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@
<arg name="output/objects" default="/perception/object_recognition/detection/rois0"/>
<arg name="model_name" default="yolox-tiny"/>
<arg name="data_path" default="$(env HOME)/autoware_data" description="packages data and artifacts directory path"/>
<arg name="yolox_param_path" default="$(find-pkg-share tensorrt_yolox)/config/yolox_tiny.param.yaml"/>
<arg name="yolox_param_path" default="$(find-pkg-share autoware_tensorrt_yolox)/config/yolox_tiny.param.yaml"/>
<arg name="use_decompress" default="true" description="use image decompress"/>
<arg name="build_only" default="false" description="exit after trt engine is built"/>

<arg name="param_file" default="$(find-pkg-share image_transport_decompressor)/config/image_transport_decompressor.param.yaml"/>
<node pkg="image_transport_decompressor" exec="image_transport_decompressor_node" name="image_transport_decompressor_node" if="$(var use_decompress)">
<remap from="~/input/compressed_image" to="$(var input/image)/compressed"/>
<remap from="~/output/raw_image" to="$(var input/image)"/>
<param from="$(var param_file)"/>
</node>

<node pkg="tensorrt_yolox" exec="tensorrt_yolox_node_exe" name="tensorrt_yolox" output="screen">
<node pkg="autoware_tensorrt_yolox" exec="autoware_tensorrt_yolox_node_exe" name="tensorrt_yolox" output="screen">
<remap from="~/in/image" to="$(var input/image)"/>
<remap from="~/out/objects" to="$(var output/objects)"/>
<param from="$(var yolox_param_path)" allow_substs="true"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<package format="3">
<name>tensorrt_yolox</name>
<name>autoware_tensorrt_yolox</name>
<version>0.0.1</version>
<description>tensorrt library implementation for yolox</description>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include <tensorrt_yolox/preprocess.hpp>
#include <autoware/tensorrt_yolox/preprocess.hpp>

#include <stdio.h>
#include <stdlib.h>
Expand All @@ -21,7 +21,7 @@

#define MIN(x, y) x < y ? x : y

namespace tensorrt_yolox
namespace autoware::tensorrt_yolox
{
constexpr size_t block = 512;

Expand Down Expand Up @@ -629,4 +629,4 @@ void argmax_gpu(
N, dst, src, d_h, d_w, s_c, s_h, s_w, batch);
}

} // namespace tensorrt_yolox
} // namespace autoware::tensorrt_yolox
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 TIER IV, Inc.

Check notice on line 1 in perception/autoware_tensorrt_yolox/src/tensorrt_yolox.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

ℹ Getting worse: Lines of Code in a Single File

The lines of code increases from 1054 to 1055, improve code health by reducing it to 1000. The number of Lines of Code in a single file. More Lines of Code lowers the code health.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -15,10 +15,10 @@
#include "cuda_utils/cuda_check_error.hpp"
#include "cuda_utils/cuda_unique_ptr.hpp"

#include <autoware/tensorrt_yolox/calibrator.hpp>
#include <autoware/tensorrt_yolox/preprocess.hpp>
#include <autoware/tensorrt_yolox/tensorrt_yolox.hpp>
#include <experimental/filesystem>
#include <tensorrt_yolox/calibrator.hpp>
#include <tensorrt_yolox/preprocess.hpp>
#include <tensorrt_yolox/tensorrt_yolox.hpp>

#include <assert.h>

Expand Down Expand Up @@ -104,9 +104,9 @@
return fileList;
}

std::vector<tensorrt_yolox::Colormap> get_seg_colormap(const std::string & filename)
std::vector<autoware::tensorrt_yolox::Colormap> get_seg_colormap(const std::string & filename)

Check warning on line 107 in perception/autoware_tensorrt_yolox/src/tensorrt_yolox.cpp

View check run for this annotation

Codecov / codecov/patch

perception/autoware_tensorrt_yolox/src/tensorrt_yolox.cpp#L107

Added line #L107 was not covered by tests
{
std::vector<tensorrt_yolox::Colormap> seg_cmap;
std::vector<autoware::tensorrt_yolox::Colormap> seg_cmap;
if (filename != "not-specified") {
std::vector<std::string> color_list = loadListFromTextFile(filename);
for (int i = 0; i < static_cast<int>(color_list.size()); i++) {
Expand All @@ -115,7 +115,7 @@
continue;
}
std::string colormapString = color_list[i];
tensorrt_yolox::Colormap cmap;
autoware::tensorrt_yolox::Colormap cmap;
size_t npos = colormapString.find_first_of(',');
assert(npos != std::string::npos);
std::string substr = colormapString.substr(0, npos);
Expand Down Expand Up @@ -151,7 +151,7 @@

} // anonymous namespace

namespace tensorrt_yolox
namespace autoware::tensorrt_yolox
{
TrtYoloX::TrtYoloX(
const std::string & model_path, const std::string & precision, const int num_class,
Expand Down Expand Up @@ -1247,7 +1247,8 @@
}

void TrtYoloX::getColorizedMask(
const std::vector<tensorrt_yolox::Colormap> & colormap, const cv::Mat & mask, cv::Mat & cmask)
const std::vector<autoware::tensorrt_yolox::Colormap> & colormap, const cv::Mat & mask,
cv::Mat & cmask)
{
int width = mask.cols;
int height = mask.rows;
Expand All @@ -1264,4 +1265,4 @@
}
}

} // namespace tensorrt_yolox
} // namespace autoware::tensorrt_yolox
Loading
Loading