tensorflow / tensorflow/models

InaccessibleTensorError while using the ssd_random_crop preprocessing function in object_detection api

Open
#10,443 0 comments 0 reactions 3 assignees View on GitHub

@pkulzc is already working on this.

Since Jan 3, 2022.

models:research:odapi type:bug
Dominant language
Python
Stars
77.7k
Forks
44.8k
PR merge metrics
No merged PRs in 30d

Description

Hello,
I was trying to use the preprocessor.py script in object_detection api to use the ssd_random_crop pre-processing function. However, i am getting InaccessibleTensorError error for which the partial stack-trace is copied below.

I am using tf-1.15 and the structure of the code block I am using to make a call to preprocessor.preprocess() is as follows. The error occurs on the 2nd iteration of the for loop below.

preprocessed_batch_images = []
preprocessed_batch_boxes = []
preprocessed_batch_labels = []

for img, box, label in zip(tf.unstack(batch_images), tf.unstack(batch_boxes), tf.unstack(batch_labels)):
    preprocessed_image, preprocessed_box, preprocessed_label = preprocessor.preprocess(......) # ERROR  
    preprocessed_batch_images.append(preprocessed_image)
    preprocessed_batch_boxes.append(preprocessed_box)
    preprocessed_batch_labels.append(preprocessed_label)

I would really appreciate if someone could point what might be causing the error.


`   raise e.ag_error_metadata.to_exception(e)
tensorflow.python.framework.errors_impl.InaccessibleTensorError: in converted code:

    train.py:618 None  *
        dataset = dataset.map(lambda clip, boxes, labels, row_lengths, \
    ~/obj_det/input_data_stad.py:761 preprocess_clip_gt_bbox_and_gt_label  *
        clip, boxes, labels, row_lengths, true_image_shapes = ssd_random_crop_clip(clip, boxes, labels,
    ~/obj_det/input_data_stad.py:920 ssd_random_crop_clip  *
        preprocessed_tensor_dict = preprocessor.preprocess(tensor_dict,
    ~/obj_det/object_detection/core/preprocessor.py:4763 preprocess  *
        results = func(*args, **params)
    ~/obj_det/object_detection/core/preprocessor.py:3638 random_crop_selector  *
        return random_crop_image(
    ~/obj_det/object_detection/core/preprocessor.py:165 _apply_with_random_selector_tuples  *
        output = func(tuple(new_x), case)
    /tmp/tmpz7idnii_.py:180 random_crop_selector
        retval__1 = random_crop_selector_scope.mark_return_value(ag__.converted_call(random_crop_image, random_crop_selector_scope.callopts, (), {'image': image, 'boxes': boxes, 'labels': labels, 'label_weights': selected_label_weights, 'label_confidences': selected_label_confidences, 'multiclass_scores': selected_multiclass_scores, 'masks': selected_masks, 'keypoints': selected_keypoints, 'min_object_covered': min_object_covered[index], 'aspect_ratio_range': aspect_ratio_range[index], 'area_range': area_range[index], 'overlap_thresh': overlap_thresh[index], 'clip_boxes': clip_boxes[index], 'random_coef': random_coef[index], 'seed': seed, 'preprocess_vars_cache': preprocess_vars_cache}, random_crop_selector_scope))
    ~/obj_det/object_detection/core/preprocessor.py:1833 random_crop_image  *
        result = tf.cond(do_a_crop_random, strict_random_crop_image_fn,
    ~/tf-1.15/lib/python3.8/site-packages/tensorflow_core/python/util/deprecation.py:513 new_func
        return func(*args, **kwargs)
    ~/tf-1.15/lib/python3.8/site-packages/tensorflow_core/python/ops/control_flow_ops.py:1174 cond
        return cond_v2.cond_v2(pred, true_fn, false_fn, name)
    ~/tf-1.15/lib/python3.8/site-packages/tensorflow_core/python/ops/cond_v2.py:94 cond_v2
        return _build_cond(
    ~/tf-1.15/lib/python3.8/site-packages/tensorflow_core/python/ops/cond_v2.py:268 _build_cond
        tensors = op_fn(
    ~/tf-1.15/lib/python3.8/site-packages/tensorflow_core/python/ops/gen_functional_ops.py:787 stateless_if
        _, _, _op = _op_def_lib._apply_op_helper(
    ~/tf-1.15/lib/python3.8/site-packages/tensorflow_core/python/framework/op_def_library.py:792 _apply_op_helper
        op = g.create_op(op_type_name, inputs, dtypes=None, name=scope,
    ~/tf-1.15/lib/python3.8/site-packages/tensorflow_core/python/framework/func_graph.py:544 create_op
        inp = self.capture(inp)
    ~/tf-1.15/lib/python3.8/site-packages/tensorflow_core/python/framework/func_graph.py:598 capture
        raise errors.InaccessibleTensorError(

    InaccessibleTensorError: The tensor 'Tensor("RandomCropImage/sample_distorted_bounding_box/SampleDistortedBoundingBoxV2:0", shape=(3,), dtype=int32)' cannot be accessed here: it is defined in another function or code block. Use return values, explicit Python locals or TensorFlow collections to access it. Defined in: FuncGraph(name=cond_2_true_823, id=140694641236096); accessed from: FuncGraph(name=Dataset_map_<lambda>, id=140694664391312).
    
`

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.