Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
236 views
in Technique[技术] by (71.8m points)

python - Tensorflow error: tfds build not supported yet

I want to create a dataset from my images in Tensorflow. I follow this instruction. I have added my code to the main dataset definition file and run tfds build. tfds build outputs this error message:

Traceback (most recent call last):
  File "C:Program FilesWindowsAppsPythonSoftwareFoundation.Python.3.7_3.7.2544.0_x64__qbz5n2kfra8p0lib
unpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
  File "C:Program FilesWindowsAppsPythonSoftwareFoundation.Python.3.7_3.7.2544.0_x64__qbz5n2kfra8p0lib
unpy.py", line 85, in _run_code
exec(code, run_globals)
  File "C:UsersUserDesktopProjectsmlScriptsfds.exe\__main__.py", line 7, in <module>
  File "c:usersuserdesktopprojectsmllibsite-packagesensorflow_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-packagesensorflow_datasetsscriptsclimain.py", line 56, in main
args.subparser_fn(args)
  File "c:usersuserdesktopprojectsmllibsite-packagesensorflow_datasetsscriptscliuild.py", line 37, in _build_datasets
raise NotImplementedError('tfds build not supported yet (#2447).')
NotImplementedError: tfds build not supported yet (#2447).

What does in mean: "tfds build not supported yet"? And my file is not even mentioned in this message. Please tell me what could be the matter?

Just in case, my file with the description of the dataset:

"""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("")
            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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...