Skip to content

Instantly share code, notes, and snippets.

@Tony607
Created April 22, 2019 01:10
Show Gist options
  • Save Tony607/bee264d510dbf1b4ce9d62df5b9cceab to your computer and use it in GitHub Desktop.
Save Tony607/bee264d510dbf1b4ce9d62df5b9cceab to your computer and use it in GitHub Desktop.
How to run TensorFlow Object Detection model on Jetson Nano | DLology
from IPython.display import Image as DisplayImage
# Boxes unit in pixels (image coordinates).
boxes_pixels = []
for i in range(num_detections):
# scale box to image coordinates
box = boxes[i] * np.array([image.shape[0],
image.shape[1], image.shape[0], image.shape[1]])
box = np.round(box).astype(int)
boxes_pixels.append(box)
boxes_pixels = np.array(boxes_pixels)
# Remove overlapping boxes with non-max suppression, return picked indexes.
pick = non_max_suppression(boxes_pixels, scores[:num_detections], 0.5)
for i in pick:
box = boxes_pixels[i]
box = np.round(box).astype(int)
# Draw bounding box.
image = cv2.rectangle(
image, (box[1], box[0]), (box[3], box[2]), (0, 255, 0), 2)
label = "{}:{:.2f}".format(int(classes[i]), scores[i])
# Draw label (class index and probability).
draw_label(image, (box[1], box[0]), label)
# Save and display the labeled image.
save_image(image[:, :, ::-1])
DisplayImage(filename="./data/img.png")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment