Reputation: 15
I'm super new to this topic of object detection and TensorFlow and I was wondering how can I load this file as a TensorFlow dataset? I've used pandas to read it as a DataFrame but I can't parse it to a TensorFlow dataset. I've tried this
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
)
)
but could not figure out how to get the annotations to work here... Any help with that?
Upvotes: 1
Views: 1570
Reputation:
Looks like your data is in JSON format,
Directly use tf.io.decode_json_example
library to read the json values.
import tensorflow as tf
tf.io.decode_json_example([
[example_json, example_json],
[example_json, example_json]]).shape.as_list()
For more details on the library find here.
Upvotes: 1