Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Issue #1903 path variable #2016

Merged
merged 2 commits into from
Aug 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions docs/source/user_guide/dataset_creation/datasets.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2225,6 +2225,7 @@ where `dataset.yaml` contains the following information:

.. code-block:: text

path: <dataset_dir> # optional
train: ./images/train/
val: ./images/val/

Expand All @@ -2238,7 +2239,9 @@ See `this page <https://docs.ultralytics.com/tutorials/train-custom-datasets>`_
for a full description of the possible format of `dataset.yaml`. In particular,
the dataset may contain one or more splits with arbitrary names, as the
specific split being imported or exported is specified by the `split` argument
to :class:`fiftyone.utils.yolo.YOLOv5DatasetImporter`.
to :class:`fiftyone.utils.yolo.YOLOv5DatasetImporter`. `dataset.yaml` can also
be located outside of `<dataset_dir>` as long as the optional `path` is set to
point to `<dataset_dir>`.

.. note::

Expand All @@ -2259,7 +2262,9 @@ where `<target>` is the zero-based integer index of the object class label from
`[0, 1] x [0, 1]`, and `<confidence>` is an optional detection confidence in
`[0, 1]`.

Unlabeled images have no corresponding TXT file in `labels/`.
Unlabeled images have no corresponding TXT file in `labels/`. The label file
path for each image is obtained by replacing `images/` with `labels/` in the
respective image path.

The image and labels directories for a given split may contain nested
subfolders of parallelly organized images and labels.
Expand Down
9 changes: 7 additions & 2 deletions docs/source/user_guide/export_datasets.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2192,6 +2192,7 @@ where `dataset.yaml` contains the following information:

.. code-block:: text

path: <dataset_dir> # optional
train: ./images/train/
val: ./images/val/

Expand All @@ -2205,7 +2206,9 @@ See `this page <https://docs.ultralytics.com/tutorials/train-custom-datasets>`_
for a full description of the possible format of `dataset.yaml`. In particular,
the dataset may contain one or more splits with arbitrary names, as the
specific split being imported or exported is specified by the `split` argument
to :class:`fiftyone.utils.yolo.YOLOv5DatasetExporter`.
to :class:`fiftyone.utils.yolo.YOLOv5DatasetExporter`. `dataset.yaml` can also
be located outside of `<dataset_dir>` as long as the optional `path` is set to
point to `<dataset_dir>`.

The TXT files in `labels/` are space-delimited files where each row corresponds
to an object in the image of the same name, in one of the following formats:
Expand All @@ -2221,7 +2224,9 @@ where `<target>` is the zero-based integer index of the object class label from
be included only if you pass the optional `include_confidence=True` flag to
the export.

Unlabeled images have no corresponding TXT file in `labels/`.
Unlabeled images have no corresponding TXT file in `labels/`. The label file
path for each image is obtained by replacing `images/` with `labels/` in the
respective image path.

.. note::

Expand Down
3 changes: 2 additions & 1 deletion fiftyone/utils/yolo.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,8 @@ def setup(self):
% (self.yaml_path, self.split)
)

data = d[self.split]
dataset_path = d.get("path", "")
data = os.path.join(dataset_path, d[self.split])
classes = d.get("names", None)

if etau.is_str(data) and data.endswith(".txt"):
Expand Down