Skip to content

Instantly share code, notes, and snippets.

@savan77
Last active October 20, 2020 21:48
Show Gist options
  • Select an option

  • Save savan77/74d82b6f533ba884763390bca94ac812 to your computer and use it in GitHub Desktop.

Select an option

Save savan77/74d82b6f533ba884763390bca94ac812 to your computer and use it in GitHub Desktop.
TF Inference Script
scores = detection_graph.get_tensor_by_name('detection_scores:0')
classes = detection_graph.get_tensor_by_name('detection_classes:0')
num_detections = detection_graph.get_tensor_by_name('num_detections:0')
(boxes, scores, classes, num_detections) = sess.run([boxes, scores, classes, num_detections], feed_dict={image_tensor: image_np_expanded})
result = []
for i in range(len(classes[0])):
if scores[0][i] >= 0.5:
xmin, ymin, xmax, ymax = _normalize_box(boxes[0][i], width, height)
label = CLASSES[classes[0][i]]
result.append({'label':label, 'xmin': xmin, 'ymin':ymin, 'xmax':xmax, 'ymax':ymax})
output['annotations'][imagePath] = result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment