python CVAT的TFRecord导出是否不正确?

f4t66c6m  于 2023-04-10  发布在  Python
关注(0)|答案(1)|浏览(132)

ML新手在这里…
这学期的后半学期我一直在为我大学的企业项目研究一个物体检测模型(有点像学校赞助的业务)。我决定使用TF对象检测API,因为它似乎抽象了许多机器学习的细节,并给了我交叉训练健壮模型的选择。虽然我讨厌不知道我的代码的细节,在我被告知的时间范围内深入了解机器学习和TF是不太可行的。
我使用CVAT's web version标注了我所有的图像,因为它宣传了自动导出。我一直在YouTube上跟随Nicholas Renotte的对象检测视频。在我尝试开始训练之前,一切都进行得相对顺利,并遇到了以下错误。

Traceback (most recent call last):
  File "/home/blake/TFOD/GM/Tensorflow/models/research/object_detection/model_main_tf2.py", line 114, in <module>
    tf.compat.v1.app.run()
  File "/home/blake/miniconda3/envs/tf/lib/python3.9/site-packages/tensorflow/python/platform/app.py", line 36, in run
    _run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
  File "/home/blake/miniconda3/envs/tf/lib/python3.9/site-packages/absl/app.py", line 308, in run
    _run_main(main, args)
  File "/home/blake/miniconda3/envs/tf/lib/python3.9/site-packages/absl/app.py", line 254, in _run_main
    sys.exit(main(argv))
  File "/home/blake/TFOD/GM/Tensorflow/models/research/object_detection/model_main_tf2.py", line 105, in main
    model_lib_v2.train_loop(
  File "/home/blake/miniconda3/envs/tf/lib/python3.9/site-packages/object_detection/model_lib_v2.py", line 605, in train_loop
    load_fine_tune_checkpoint(
  File "/home/blake/miniconda3/envs/tf/lib/python3.9/site-packages/object_detection/model_lib_v2.py", line 401, in load_fine_tune_checkpoint
    _ensure_model_is_built(model, input_dataset, unpad_groundtruth_tensors)
  File "/home/blake/miniconda3/envs/tf/lib/python3.9/site-packages/object_detection/model_lib_v2.py", line 161, in _ensure_model_is_built
    features, labels = iter(input_dataset).next()
  File "/home/blake/miniconda3/envs/tf/lib/python3.9/site-packages/tensorflow/python/distribute/input_lib.py", line 570, in next
    return self.__next__()
  File "/home/blake/miniconda3/envs/tf/lib/python3.9/site-packages/tensorflow/python/distribute/input_lib.py", line 574, in __next__
    return self.get_next()
  File "/home/blake/miniconda3/envs/tf/lib/python3.9/site-packages/tensorflow/python/distribute/input_lib.py", line 631, in get_next
    return self._get_next_no_partial_batch_handling(name)
  File "/home/blake/miniconda3/envs/tf/lib/python3.9/site-packages/tensorflow/python/distribute/input_lib.py", line 663, in _get_next_no_partial_batch_handling
    replicas.extend(self._iterators[i].get_next_as_list(new_name))
  File "/home/blake/miniconda3/envs/tf/lib/python3.9/site-packages/tensorflow/python/distribute/input_lib.py", line 1633, in get_next_as_list
    return self._format_data_list_with_options(self._iterator.get_next())
  File "/home/blake/miniconda3/envs/tf/lib/python3.9/site-packages/tensorflow/python/data/ops/multi_device_iterator_ops.py", line 554, in get_next
    result.append(self._device_iterators[i].get_next())
  File "/home/blake/miniconda3/envs/tf/lib/python3.9/site-packages/tensorflow/python/data/ops/iterator_ops.py", line 850, in get_next
    return self._next_internal()
  File "/home/blake/miniconda3/envs/tf/lib/python3.9/site-packages/tensorflow/python/data/ops/iterator_ops.py", line 780, in _next_internal
    ret = gen_dataset_ops.iterator_get_next(
  File "/home/blake/miniconda3/envs/tf/lib/python3.9/site-packages/tensorflow/python/ops/gen_dataset_ops.py", line 3016, in iterator_get_next
    _ops.raise_from_not_ok_status(e, name)
  File "/home/blake/miniconda3/envs/tf/lib/python3.9/site-packages/tensorflow/python/framework/ops.py", line 7262, in raise_from_not_ok_status
    raise core._status_to_exception(e) from None  # pylint: disable=protected-access
tensorflow.python.framework.errors_impl.InvalidArgumentError: {{function_node __wrapped__IteratorGetNext_output_types_16_device_/job:localhost/replica:0/task:0/device:GPU:0}} Input is empty.
     [[{{function_node case_cond_cond_jpeg_false_220}}{{node case/cond/cond_jpeg/decode_image/DecodeImage}}]]
     [[MultiDeviceIteratorGetNextFromShard]]
     [[RemoteCall]] [Op:IteratorGetNext]

我在WSL 2上的Ubuntu 22.04.1上运行TF 2.12.0。
据我所知,这个错误表明我的TFRecords有问题。(约300张图像)和13 KB的测试数据集(~25个图像,每个图像有4个对象)。我认为TFRecord包含图像和注解数据,以二进制格式供TF使用,所以这两个文件大小看起来都小得可笑。
是CFAT的TFRecord导出有问题,还是我误解了导出或TFRecords的使用?
如果CVAT的导出有问题,是否可以以其他格式导出并转换为TFRecord?Nicholas Renotte的视频推荐使用LabelImg,他提供了一个脚本将LabelImg的输出转换为TFRecord。遵循这个脚本是更好的选择吗?当然,我不希望重新注解我的图像。任何正确方向的指导或推动都将不胜感激。

raogr8fs

raogr8fs1#

我假设CVAT的TFRecord导出被破坏了。
我最终在CVAT上导出到PASCAL,因为这是LabelImg使用的.XML格式。然后我创建了一个train目录,并粘贴了所有训练图像及其各自的.XML文件。测试目录也是如此。
我使用this repo从图像和.XML文件创建TFRecords。唯一的修改是在第85-91行。int()转换被更改为float()转换,因为CVAT创建浮点坐标。LabelImg创建整数坐标。

相关问题