问题
I want to load the tensorflow flowers dataset and visualize it using tfds.show_examples.
import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
import tensorflow_hub as hub
import tensorflow_datasets as tfds
from tensorflow.keras import layers
import logging
logger = tf.get_logger()
logger.setLevel(logging.ERROR)
(train_examples, validation_examples), info = tfds.load(
'tf_flowers',
with_info=True,
as_supervised=True,
split=['train[:70%]', 'train[70%:]'],
)
fig = tfds.show_examples(train_examples, info)
When I run my code, instead of seeing images, I get an error message:
AttributeError Traceback (most recent call last)
<ipython-input-13-dcdedbcd800d> in <module>()
6 )
7
----> 8 fig = tfds.show_examples(train_examples, info)
/usr/local/lib/python3.6/dist-packages/tensorflow_datasets/core/visualization.py in show_examples(ds_info, ds, rows, cols, plot_scale, image_key)
68 # Infer the image and label keys
69 image_keys = [
---> 70 k for k, feature in ds_info.features.items()
71 if isinstance(feature, features_lib.Image)
72 ]
AttributeError: 'DatasetV1Adapter' object has no attribute 'features'
Why is this not working?
回答1:
I had the same problem using Colab. Try this
pip install --upgrade tensorflow-datasets
and restart the kernel
来源:https://stackoverflow.com/questions/62582022/show-examples-in-tensorflow-datasets-not-working