Skip to content

Add YOLO-World Model Support in tracker_node.py #74

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

Open
wants to merge 2 commits into
base: noetic-devel
Choose a base branch
from
Open
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
8 changes: 7 additions & 1 deletion script/tracker_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,13 @@ def __init__(self):
self.result_boxes = rospy.get_param("~result_boxes", True)
path = roslib.packages.get_pkg_dir("ultralytics_ros")
self.model = YOLO(f"{path}/models/{yolo_model}")
self.model.fuse()
use_world = "world" in yolo_model.lower()
if use_world:
if self.classes is not None:
self.model.set_classes(self.classes)
self.classes = None
else:
self.model.fuse()
self.sub = rospy.Subscriber(
self.input_topic,
Image,
Expand Down
3 changes: 2 additions & 1 deletion src/tracker_with_cloud_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,15 @@ void TrackerWithCloudNode::syncCallback(const sensor_msgs::CameraInfo::ConstPtr&
pcl::PointCloud<pcl::PointXYZ>::Ptr downsampled_cloud(new pcl::PointCloud<pcl::PointXYZ>);
downsampled_cloud = downsampleCloudMsg(cloud_msg);

cam_model_.fromCameraInfo(camera_info_msg);

pcl::PointCloud<pcl::PointXYZ>::Ptr transformed_cloud;
transformed_cloud = cloud2TransformedCloud(downsampled_cloud, cloud_msg->header.frame_id, cam_model_.tfFrame(),
cloud_msg->header.stamp);
vision_msgs::Detection3DArray detections3d_msg;
sensor_msgs::PointCloud2 detection_cloud_msg;
visualization_msgs::MarkerArray marker_array_msg;

cam_model_.fromCameraInfo(camera_info_msg);
projectCloud(transformed_cloud, yolo_result_msg, cloud_msg->header, detections3d_msg, detection_cloud_msg);
marker_array_msg = createMarkerArray(detections3d_msg, callback_interval.toSec());

Expand Down