diff --git a/Containers/PyTorch.Dockerfile b/Containers/PyTorch.Dockerfile new file mode 100644 index 0000000..656880c --- /dev/null +++ b/Containers/PyTorch.Dockerfile @@ -0,0 +1,8 @@ +FROM nvcr.io/nvidia/pytorch:24.08-py3 + +COPY ../conversion_tools /conversion_tools + +# ORT +RUN pip3 install -U --no-cache-dir --verbose jetson-stats numpy onnx pycuda ultralytics + +ENTRYPOINT [ "/bin/bash" ] \ No newline at end of file diff --git a/Containers/TensorFlow.Dockerfile b/Containers/TensorFlow.Dockerfile new file mode 100644 index 0000000..e69de29 diff --git a/Conversion Tools/ONNX_TRT.py b/conversion_tools/ONNX_TRT.py similarity index 100% rename from Conversion Tools/ONNX_TRT.py rename to conversion_tools/ONNX_TRT.py diff --git a/Conversion Tools/PT_ONNX.py b/conversion_tools/PT_ONNX.py similarity index 100% rename from Conversion Tools/PT_ONNX.py rename to conversion_tools/PT_ONNX.py diff --git a/Conversion Tools/PT_TRT.py b/conversion_tools/PT_TRT.py similarity index 100% rename from Conversion Tools/PT_TRT.py rename to conversion_tools/PT_TRT.py diff --git a/Conversion Tools/README.md b/conversion_tools/README.md similarity index 100% rename from Conversion Tools/README.md rename to conversion_tools/README.md diff --git a/Conversion Tools/TF_ONNX.py b/conversion_tools/TF_ONNX.py similarity index 100% rename from Conversion Tools/TF_ONNX.py rename to conversion_tools/TF_ONNX.py diff --git a/Conversion Tools/TF_TRT.py b/conversion_tools/TF_TRT.py similarity index 100% rename from Conversion Tools/TF_TRT.py rename to conversion_tools/TF_TRT.py diff --git a/Conversion Tools/TRT_Benchmark.py b/conversion_tools/TRT_Benchmark.py similarity index 100% rename from Conversion Tools/TRT_Benchmark.py rename to conversion_tools/TRT_Benchmark.py diff --git a/ros2_ws/src/python_workspace/python_workspace/camera_node.py b/ros2_ws/src/python_workspace/python_workspace/camera_node.py index bf61984..722fb36 100644 --- a/ros2_ws/src/python_workspace/python_workspace/camera_node.py +++ b/ros2_ws/src/python_workspace/python_workspace/camera_node.py @@ -152,12 +152,12 @@ def publish_zed_frames(self): gpu_image.upload(cv_image) # Transform to BGR8 format and resize using CUDA - cv2.cuda.cvtColor(gpu_image, cv2.COLOR_BGR2RGB) + cv2.cuda.cvtColor(gpu_image, cv2.COLOR_BGRA2RGB) cv2.cuda.resize(gpu_image, self.dimensions) # Convert the image to float32 - image_gpu = image_gpu.transpose((2, 0, 1)).astype(np.float32) - image_gpu = np.expand_dims(image_gpu, axis=0) + # gpu_image = gpu_image.transpose((2, 0, 1)).astype(np.float32) + # gpu_image = np.expand_dims(gpu_image, axis=0) # # Transpose the image # image_gpu = cv2.cuda.transpose(image_gpu) @@ -194,7 +194,7 @@ def publish_image(self, image): image = gpu_image.download() # does this update outside scope? try: - image_msg = self.bridge.cv2_to_imgmsg(image, encoding='rgb8') + image_msg = self.bridge.cv2_to_imgmsg(image, encoding='8UC4') # rgb8 except CvBridgeError as e: print(e) @@ -202,7 +202,7 @@ def publish_image(self, image): image_msg.is_bigendian = 0 image_msg.step = image_msg.width * 3 - self.model_publisher.publish(image_msg) + self.publisher.publish(image_msg) size = sys.getsizeof(image_msg) self.get_logger().info(f'Published image frame: {self.index} with message size {size} bytes') time.sleep(1.0 / self.frame_rate) # delay to control framerate diff --git a/ros2_ws/src/python_workspace/python_workspace/jetson_node.py b/ros2_ws/src/python_workspace/python_workspace/jetson_node.py index bf1f00b..90ebb68 100644 --- a/ros2_ws/src/python_workspace/python_workspace/jetson_node.py +++ b/ros2_ws/src/python_workspace/python_workspace/jetson_node.py @@ -18,8 +18,9 @@ class JetsonNode(Node): def __init__(self): super().__init__('jetson_node') self.declare_parameter('engine_path', '.../assets/model.trt') + self.engine_path = self.get_parameter('engine_path').get_parameter_value().string_value - self.camera_subscriber = self.create_subscription(Image, 'image_data', self.callback, 10) + self.camera_subscriber = self.create_subscription(Image, 'image_data', self.image_callback, 10) self.bbox_publisher = self.create_publisher(String, 'bounding_boxes', 10) self.bridge = CvBridge() self.engine = self.load_engine(self.engine_path) @@ -57,7 +58,7 @@ def allocate_buffers(self): # Create a CUDA stream for async execution self.stream = cuda.Stream() - def listener_callback(self, msg): + def image_callback(self, msg): now = self.get_clock().now() self.get_logger().info(f"Received: {msg.header.frame_id}") latency = now - Time.from_msg(msg.header.stamp)