Skip to content

Commit

Permalink
renamed directory + pytorch image
Browse files Browse the repository at this point in the history
  • Loading branch information
Ishaan-Datta committed Sep 11, 2024
1 parent 7b5e4ef commit 325abae
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 7 deletions.
8 changes: 8 additions & 0 deletions Containers/PyTorch.Dockerfile
Original file line number Diff line number Diff line change
@@ -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" ]
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions ros2_ws/src/python_workspace/python_workspace/camera_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -194,15 +194,15 @@ 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)

image_msg.header = header
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
Expand Down
5 changes: 3 additions & 2 deletions ros2_ws/src/python_workspace/python_workspace/jetson_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 325abae

Please sign in to comment.