-
Notifications
You must be signed in to change notification settings - Fork 45.4k
DeepLab: Cityscapes splits refactoring #8870
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -113,17 +113,23 @@ def _get_files(data, dataset_split): | |
|
|
||
| Args: | ||
| data: String, desired data ('image' or 'label'). | ||
| dataset_split: String, dataset split ('train', 'val', 'test') | ||
| dataset_split: String, dataset split ('train_fine', 'val_fine', 'test_fine') | ||
|
|
||
| Returns: | ||
| A list of sorted file names or None when getting label for | ||
| test set. | ||
| """ | ||
| if data == 'label' and dataset_split == 'test': | ||
| return None | ||
| if dataset_split == 'train_fine': | ||
| split_dir = 'train' | ||
| elif dataset_split == 'val_fine': | ||
ruslo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| split_dir = 'val' | ||
| elif dataset_split == 'test_fine': | ||
| split_dir = 'test' | ||
| else: | ||
| raise RuntimeError("Split {} is not supported".format(dataset_split)) | ||
| pattern = '*%s.%s' % (_POSTFIX_MAP[data], _DATA_FORMAT_MAP[data]) | ||
| search_files = os.path.join( | ||
| FLAGS.cityscapes_root, _FOLDERS_MAP[data], dataset_split, '*', pattern) | ||
| FLAGS.cityscapes_root, _FOLDERS_MAP[data], split_dir, '*', pattern) | ||
| filenames = glob.glob(search_files) | ||
| return sorted(filenames) | ||
|
|
||
|
|
@@ -132,7 +138,7 @@ def _convert_dataset(dataset_split): | |
| """Converts the specified dataset split to TFRecord format. | ||
|
|
||
| Args: | ||
| dataset_split: The dataset split (e.g., train, val). | ||
| dataset_split: The dataset split (e.g., train_fine, val_fine). | ||
|
|
||
| Raises: | ||
| RuntimeError: If loaded image and label have different shape, or if the | ||
|
|
@@ -152,7 +158,7 @@ def _convert_dataset(dataset_split): | |
| label_reader = build_data.ImageReader('png', channels=1) | ||
|
|
||
| for shard_id in range(_NUM_SHARDS): | ||
| shard_filename = '%s_fine-%05d-of-%05d.tfrecord' % ( | ||
| shard_filename = '%s-%05d-of-%05d.tfrecord' % ( | ||
| dataset_split, shard_id, _NUM_SHARDS) | ||
| output_filename = os.path.join(FLAGS.output_dir, shard_filename) | ||
| with tf.python_io.TFRecordWriter(output_filename) as tfrecord_writer: | ||
|
|
@@ -183,8 +189,8 @@ def _convert_dataset(dataset_split): | |
|
|
||
|
|
||
| def main(unused_argv): | ||
| # Only support converting 'train' and 'val' sets for now. | ||
| for dataset_split in ['train', 'val']: | ||
| # Only support converting 'train_fine', 'val_fine' and 'test_fine' sets for now. | ||
| for dataset_split in ['train_fine', 'val_fine', 'test_fine']: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's change it back to for dataset_split in ['train_fine', 'val_fine']: It seems that we need to do more changes in order to support test_fine (e.g., skip reading groundtruth).
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I can change it back, but as I said, the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, yes, you are right. I totally forgot that Cityscapes has default groundtruth (all ignore labels) for test set.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are right. Thanks for double-checking it, ruslo! |
||
| _convert_dataset(dataset_split) | ||
|
|
||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We still need this, since test_fine does not have label.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The files themselves are there, but they don't contain useful information:
Example of a list of labels from the train set:
Example of a list of labels from the test set:
Basically, they are all the same in the test set (as far as I understand):
If you add this line to
build_cityscapes_data.py:Output will be:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for double-checking it, ruslo!