question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Unable to convert COCO to TensorFlow dataset

See original GitHub issue

Calling .to_tensorflow() on any of the COCO datasets yields TypeError. It happens for both TensorFlow 1.x and TensorFlow 2.x.

The problematic code:

import hub
ds = hub.Dataset('activeloop/coco_train')
ds= ds.to_tensorflow()

Error message:

TypeError                                 Traceback (most recent call last)
<ipython-input-6-6674a34504fe> in <module>()
----> 1 gen = ds.to_tensorflow()

6 frames
/usr/local/lib/python3.6/dist-packages/hub/api/dataset.py in to_tensorflow(self, indexes)
    651 
    652         return tf.data.Dataset.from_generator(
--> 653             tf_gen, output_types=output_types, output_shapes=output_shapes
    654         )
    655 

/usr/local/lib/python3.6/dist-packages/tensorflow/python/util/deprecation.py in new_func(*args, **kwargs)
    536                 'in a future version' if date is None else ('after %s' % date),
    537                 instructions)
--> 538       return func(*args, **kwargs)
    539 
    540     doc = _add_deprecated_arg_notice_to_docstring(

/usr/local/lib/python3.6/dist-packages/tensorflow/python/data/ops/dataset_ops.py in from_generator(generator, output_types, output_shapes, args, output_signature)
    830         output_shapes = nest.map_structure_up_to(output_types,
    831                                                  tensor_shape.as_shape,
--> 832                                                  output_shapes)
    833       output_signature = nest.map_structure_up_to(output_types,
    834                                                   tensor_spec.TensorSpec,

/usr/local/lib/python3.6/dist-packages/tensorflow/python/data/util/nest.py in map_structure_up_to(shallow_tree, func, *inputs)
    462     raise ValueError("Cannot map over no sequences")
    463   for input_tree in inputs:
--> 464     assert_shallow_structure(shallow_tree, input_tree)
    465 
    466   # Flatten each input separately, apply the function to corresponding elements,

/usr/local/lib/python3.6/dist-packages/tensorflow/python/data/util/nest.py in assert_shallow_structure(shallow_tree, input_tree, check_types)
    322     for shallow_branch, input_branch in zip(shallow_tree, input_tree):
    323       assert_shallow_structure(shallow_branch, input_branch,
--> 324                                check_types=check_types)
    325 
    326 

/usr/local/lib/python3.6/dist-packages/tensorflow/python/data/util/nest.py in assert_shallow_structure(shallow_tree, input_tree, check_types)
    322     for shallow_branch, input_branch in zip(shallow_tree, input_tree):
    323       assert_shallow_structure(shallow_branch, input_branch,
--> 324                                check_types=check_types)
    325 
    326 

/usr/local/lib/python3.6/dist-packages/tensorflow/python/data/util/nest.py in assert_shallow_structure(shallow_tree, input_tree, check_types)
    303           "The two structures don't have the same sequence type. Input "
    304           "structure has type %s, while shallow structure has type %s."
--> 305           % (type(input_tree), type(shallow_tree)))
    306 
    307     if len(input_tree) != len(shallow_tree):

TypeError: The two structures don't have the same sequence type. Input structure has type <class 'tuple'>, while shallow structure has type <class 'dict'>.

Here is a GoogleColab notebook that reproduces the error: https://colab.research.google.com/drive/1tnlnqivwfgfL38U1hrCMJEDYLfhXA96-?usp=sharing

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
haiyangdepercicommented, Feb 4, 2021

@oKatanaaa the dataset without the sequence is ready for you. Just run:

ds = hub.Dataset('hydp/coco_train_workaround')
ds = ds.to_tensorflow()
0reactions
mynameisvinncommented, Feb 4, 2021

@haiyangdeperci yes, the dataset technical debt is accruing 😦

Read more comments on GitHub >

github_iconTop Results From Across the Web

Failed to running ssd workloads with COCO dataset #408
The detail error message is: tensorflow.python.framework.errors_impl.InvalidArgumentError: StringToNumberOp could not correctly convert ...
Read more >
Getting an error while converting my dataset in TFrecord ...
And i want to convert my dataset into TFRecord format but when i am running the build_voc2012_data.py file i am getting an error....
Read more >
failed to convert tensorflow ssd mobilnetv1 coco model with ...
Solved: Error : [ ERROR ] Shape [-1 -1 -1 3] is not fully defined for output 0 of "image_tensor". Use --input_shape with...
Read more >
TensorFlow Datasets
TFDS provides a collection of ready-to-use datasets for use with TensorFlow, Jax, and other Machine Learning frameworks.
Read more >
Writing custom datasets - TensorFlow
Follow this guide to create a new dataset (either in TFDS or in your own repository). Check our list of datasets to see...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found