Usage example
Closed this issue · 1 comments
Hello, thank you for your implemantation, I am trying to use your repo but there are some isues which I could not figure out. Let me explain:
ROS: Noetic
System: Ubuntu 20.04
CUDA:11.8
CuDNN:8.7
Python: 3.8
TensorRT: 8.5.3
I cloned repo to my workspace. After that I edited TensorRT location in CMake file and built workspace.
Config yaml:
tensorrt_yolov9_ros:
image_compressed: false # true: use compressed image, false: use raw image
image_topic: "/camera/image_raw" # image topic
engine_file_path: "/path_of_weight/best.trt"
confidence_thres: 0.5 # confidence threshold
nms_thres: 0.4 # nms threshold
downsampling_infer: 1 # inference every n frames, if 3, then 1/3 of images
classes: ["car"]
Model trained with yolov9-e.yaml and converted trt file by using https://github.com/laugh12321/TensorRT-YOLO/ . When I use command roslaunch tensorrt_yolov9_ros run.launch:
NODES
/
tensorrt_yolov9_ros_node (tensorrt_yolov9_ros/tensorrt_yolov9_ros_node)
auto-starting new master
process[master]: started with pid [158959]
ROS_MASTER_URI=http://localhost:11311
setting /run_id to bec91576-2067-11ef-9c64-53fb71fffb6e
process[rosout-1]: started with pid [158980]
started core service [/rosout]
process[tensorrt_yolov9_ros_node-2]: started with pid [158987]
[ WARN] [1717281543.105198370]: class heritated, starting node...
After that I am publishing my webcam to /camera/image_raw with a simple python script with.
import rospy
from sensor_msgs.msg import Image
from cv_bridge import CvBridge
import cv2
def publish_webcam():
rospy.init_node('webcam_publisher', anonymous=True)
image_pub = rospy.Publisher('/camera/image_raw', Image, queue_size=10)
bridge = CvBridge()
cap = cv2.VideoCapture(0)
if not cap.isOpened():
rospy.logerr("Unable to open webcam")
return
rate = rospy.Rate(10) # 10 Hz
while not rospy.is_shutdown():
ret, frame = cap.read()
if not ret:
rospy.logerr("Failed to capture image")
continue
image_msg = bridge.cv2_to_imgmsg(frame, "bgr8")
image_pub.publish(image_msg)
rate.sleep()
cap.release()
if __name__ == '__main__':
try:
publish_webcam()
except rospy.ROSInterruptException:
pass
Result:
[06/02/2024-01:41:31] [W] [TRT] Using an engine plan file across different models of devices is not recommended and is likely to affect performance or even cause errors.
[tensorrt_yolov9_ros_node-2] process has died [pid 158987, exit code -11, cmd /home/yusuf/catkin_ws/devel/lib/tensorrt_yolov9_ros/tensorrt_yolov9_ros_node __name:=tensorrt_yolov9_ros_node __log:=/home/yusuf/.ros/log/bec91576-2067-11ef-9c64-53fb71fffb6e/tensorrt_yolov9_ros_node-2.log].
log file: /home/yusuf/.ros/log/bec91576-2067-11ef-9c64-53fb71fffb6e/tensorrt_yolov9_ros_node-2*.log
There isn't a log file. Do you have an idea about this problem? Thank you.
@UcanYusuf Hi.
As I wrote in the README file, you should export the .pt file into .onnx first properly with the original YOLOv9 repository.
Then, proper .engine file should be generated with the /usr/src/tensorrt/bin/trtexec of your computer.
Your error already implies that the method you generated the tensorRT file is wrong.
[06/02/2024-01:41:31] [W] [TRT] Using an engine plan file across different models of devices is not recommended and is likely to affect performance or even cause errors.
Please read and follow the instructions in the README file first, and then if you get the other error again, please tell me.