Tensorflow错误:尚未支持tfds生成



我想用Tensorflow中的图像创建一个数据集。我遵循这个指示。我已经将代码添加到主数据集定义文件中,并运行tfds构建。tfds构建输出以下错误消息:

Traceback (most recent call last):
File "C:Program FilesWindowsAppsPythonSoftwareFoundation.Python.3.7_3.7.2544.0_x64__qbz5n2kfra8p0librunpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:Program FilesWindowsAppsPythonSoftwareFoundation.Python.3.7_3.7.2544.0_x64__qbz5n2kfra8p0librunpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:UsersUserDesktopProjectsmlScriptstfds.exe__main__.py", line 7, in <module>
File "c:usersuserdesktopprojectsmllibsite-packagestensorflow_datasetsscriptsclimain.py", line 61, in launch_cli
app.run(main, flags_parser=_parse_flags)
File "c:usersuserdesktopprojectsmllibsite-packagesabslapp.py", line 300, in run
_run_main(main, args)
File "c:usersuserdesktopprojectsmllibsite-packagesabslapp.py", line 251, in _run_main
sys.exit(main(argv))
File "c:usersuserdesktopprojectsmllibsite-packagestensorflow_datasetsscriptsclimain.py", line 56, in main
args.subparser_fn(args)
File "c:usersuserdesktopprojectsmllibsite-packagestensorflow_datasetsscriptsclibuild.py", line 37, in _build_datasets
raise NotImplementedError('tfds build not supported yet (#2447).')
NotImplementedError: tfds build not supported yet (#2447).

什么意思是:;尚未支持tfds构建";?我的文件甚至没有在这条消息中提及。请告诉我可能是怎么回事?

以防万一,我的文件中有数据集的描述:

"""posture1 dataset."""
import tensorflow_datasets as tfds
# TODO(posture1): Markdown description  that will appear on the catalog page.
_DESCRIPTION = """
Description is **formatted** as markdown.
It should also contain any processing which has been applied (if any),
(e.g. corrupted example skipped, images cropped,...):
"""
# TODO(posture1): BibTeX citation
_CITATION = """
"""

class Posture1(tfds.core.GeneratorBasedBuilder):
"""DatasetBuilder for posture1 dataset."""
VERSION = tfds.core.Version('1.0.0')
RELEASE_NOTES = {
'1.0.0': 'Initial release.',
}
def _info(self) -> tfds.core.DatasetInfo:
"""Returns the dataset metadata."""
# TODO(posture1): Specifies the tfds.core.DatasetInfo object
return tfds.core.DatasetInfo(
builder=self,
description=_DESCRIPTION,
features=tfds.features.FeaturesDict({
'image': tfds.features.Image(shape=(480, 640, 3)),
'label': tfds.features.ClassLabel(names=['bad', 'good']),
}),
# If there's a common (input, target) tuple from the
# features, specify them here. They'll be used if
# `as_supervised=True` in `builder.as_dataset`.
# supervised_keys=None,  # e.g. ('image', 'label')
# homepage='https://dataset-homepage/',
# citation=_CITATION,
)
def _split_generators(self, dl_manager: tfds.download.DownloadManager):
"""Returns SplitGenerators."""
# TODO(posture1): Downloads the data and defines the splits
#path = dl_manager.download_and_extract('https://todo-data-url')
# TODO(posture1): Returns the Dict[split names, Iterator[Key, Example]]
return {
'train': self._generate_examples('train'),
'test': self._generate_examples('test'),
'verify': self._generate_examples('verify'),
}
def _generate_examples(self, subset):
"""Yields examples."""
filepath = 'C:\Users\User\PycharmProjects\posture1\Dataset\data.csv'
with open(filepath) as fp:
line = fp.readline()
cnt = 0
while line:
parts = line.split("t")
if len(parts) < 2 or parts[1] == "unknown" or parts[1] == "":
continue
r = cnt % 6
if subset == "train" and r <= 3:
yield parts[0], {
'image': "C:\Users\User\PycharmProjects\posture1\Dataset\" + parts[0],
'label': parts[1],
}
if subset == "test" and r == 4:
yield parts[0], {
'image': "C:\Users\User\PycharmProjects\posture1\Dataset\" + parts[0],
'label': parts[1],
}
if subset == "verify" and r == 5:
yield parts[0], {
'image': "C:\Users\User\PycharmProjects\posture1\Dataset\" + parts[0],
'label': parts[1],
}
print("Line {}: {}".format(cnt, line.strip()))
line = fp.readline()
cnt += 1

你能试试最后一个版本的TFDS(v4.2.0+(吗?我认为这是文档和pip版本之间的不匹配

相关内容

  • 没有找到相关文章

最新更新