FurkanOM / tf-faster-rcnn

Tensorflow 2 Faster-RCNN implementation from scratch supporting to the batch processing with MobileNetV2 and VGG16 backbones
Apache License 2.0
94 stars 61 forks source link

ValueError: The two structures don't have the same sequence length. Input structure has length 0, while shallow structure has length 9. #17

Open SalehShmali opened 3 years ago

SalehShmali commented 3 years ago

can any one solve this issue please on training faster_rcnn_trainer.py

ksyoon70 commented 3 years ago

make virtual env with tensorflow version 2.1? tf ver 2.4 makes errors like above.

colindecourt commented 3 years ago

Hi, I changed the generator with the following function according to the tf2.4 documentation (https://www.tensorflow.org/api_docs/python/tf/keras/Model#fit) and it seems it works with batch size of 1. For batch size > 1 there is another issue according to #14

def faster_rcnn_generator(dataset, anchors, hyper_params):
    """Tensorflow data generator for fit method, yielding inputs and outputs.
    inputs:
        dataset = tf.data.Dataset, PaddedBatchDataset
        anchors = (total_anchors, [y1, x1, y2, x2])
            these values in normalized format between [0, 1]
        hyper_params = dictionary
    outputs:
        yield inputs, outputs
    """
    while True:
        for image_data in dataset:
            img, gt_boxes, gt_labels = image_data
            bbox_deltas, bbox_labels = calculate_rpn_actual_outputs(anchors, gt_boxes, gt_labels, hyper_params)
            yield (img, gt_boxes, gt_labels, bbox_deltas, bbox_labels), 
ruman1609 commented 2 years ago

Hi @colindecourt I encounter a error while doing with tensorflow 2.1 any idea how to handle that problem? I already open an issue #21. Feel free to drop by.