tensorflow / tensorflow/models
error running eager_few_shot_od_training_tflite in google colab
@pkulzc is already working on this.
Since Sep 20, 2021.
- Dominant language
- Python
- Stars
- 77.7k
- Forks
- 44.8k
- PR merge metrics
- No merged PRs in 30d
Description
Prerequisites
Please answer the following question for yourself before submitting an issue.
- [ x] I checked to make sure that this issue has not been filed already.
1. The entire URL of the documentation with the issue
2. Describe the issue
Running the notebook in google colab produces an error when processing the visualization of the test predictions:
/usr/local/lib/python3.7/dist-packages/object_detection/utils/visualization_utils.py in
visualize_boxes_and_labels_on_image_array(image, boxes, classes, scores, category_index, instance_masks, instance_boundaries, keypoints, keypoint_scores, keypoint_edges, track_ids, use_normalized_coordinates, max_boxes_to_draw, min_score_thresh, agnostic_mode, line_thickness, mask_alpha, groundtruth_box_visualization_color, skip_boxes, skip_scores, skip_labels, skip_track_ids)
1187 if max_boxes_to_draw == len(box_to_color_map):
1188 break
-> 1189 if scores is None or scores[i] > min_score_thresh:
1190 box = tuple(boxes[i].tolist())
1191 if instance_masks is not None:IndexError: invalid index to scalar variable.
This appears to be because the assignment of output tensors is incorrect in the detect function:
boxes = interpreter.get_tensor(output_details[0]['index'])
classes = interpreter.get_tensor(output_details[1]['index'])
scores = interpreter.get_tensor(output_details[2]['index'])
this is the output of interpreter.get_output_details():
[{'dtype': numpy.float32,
'index': 335,
'name': 'StatefulPartitionedCall:1',
'quantization': (0.0, 0),
'quantization_parameters': {'quantized_dimension': 0,
'scales': array([], dtype=float32),
'zero_points': array([], dtype=int32)},
'shape': array([ 1, 10], dtype=int32),
'shape_signature': array([ 1, 10], dtype=int32),
'sparsity_parameters': {}},
{'dtype': numpy.float32,
'index': 333,
'name': 'StatefulPartitionedCall:3',
'quantization': (0.0, 0),
'quantization_parameters': {'quantized_dimension': 0,
'scales': array([], dtype=float32),
'zero_points': array([], dtype=int32)},
'shape': array([ 1, 10, 4], dtype=int32),
'shape_signature': array([ 1, 10, 4], dtype=int32),
'sparsity_parameters': {}},
{'dtype': numpy.float32,
'index': 336,
'name': 'StatefulPartitionedCall:0',
'quantization': (0.0, 0),
'quantization_parameters': {'quantized_dimension': 0,
'scales': array([], dtype=float32),
'zero_points': array([], dtype=int32)},
'shape': array([1], dtype=int32),
'shape_signature': array([1], dtype=int32),
'sparsity_parameters': {}},
{'dtype': numpy.float32,
'index': 334,
'name': 'StatefulPartitionedCall:2',
'quantization': (0.0, 0),
'quantization_parameters': {'quantized_dimension': 0,
'scales': array([], dtype=float32),
'zero_points': array([], dtype=int32)},
'shape': array([ 1, 10], dtype=int32),
'shape_signature': array([ 1, 10], dtype=int32),
'sparsity_parameters': {}}]
re-assigning the output tensors produces the expected result:
boxes = interpreter.get_tensor(output_details[1]['index'])
classes = interpreter.get_tensor(output_details[3]['index'])
scores = interpreter.get_tensor(output_details[0]['index'])
though, I admit, I'm not sure this is the most complete way to solve this issue and whether the order of the output tensors is stable
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.