如何在 Tensorflow 中使用 COCO 对象检测数据集?

How to work with COCO object detection datasets in Tensorflow?

我对对象检测和 TensorFlow 这个主题非常陌生,我想知道如何将 this file 作为 TensorFlow 数据集加载?我使用 pandas 将其作为 DataFrame 读取,但无法将其解析为 TensorFlow 数据集。我试过这个

train_ds = tf.data.Dataset.from_tensor_slices(
  (
    tf.cast(dataframe['file'].values, tf.string),
    tf.cast(dataframe['width'].values, tf.int8),
    tf.cast(dataframe['height'].values, tf.int8)
  ),
  (
    # tf.cast(dataframe['annotations'].values, tf.string)
    # here I want to cast the annotations to the dataset but I don't 
    # know how
  )
)

但无法弄清楚如何让注释在这里工作...有什么帮助吗?

看起来你的数据是 JSON 格式, 直接使用 tf.io.decode_json_example 库读取 json 值。

import tensorflow as tf
tf.io.decode_json_example([
    [example_json, example_json],
    [example_json, example_json]]).shape.as_list()

有关库的更多详细信息,请查找 here