Commit e7667f6f authored by Kaushik Shivakumar's avatar Kaushik Shivakumar
Browse files

Merge branch 'master' of https://github.com/tensorflow/models into context_tf2

parents 974c463e 709a6617
...@@ -113,17 +113,23 @@ def _get_files(data, dataset_split): ...@@ -113,17 +113,23 @@ def _get_files(data, dataset_split):
Args: Args:
data: String, desired data ('image' or 'label'). 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: Returns:
A list of sorted file names or None when getting label for A list of sorted file names or None when getting label for
test set. test set.
""" """
if data == 'label' and dataset_split == 'test': if dataset_split == 'train_fine':
return None split_dir = 'train'
elif dataset_split == 'val_fine':
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]) pattern = '*%s.%s' % (_POSTFIX_MAP[data], _DATA_FORMAT_MAP[data])
search_files = os.path.join( 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) filenames = glob.glob(search_files)
return sorted(filenames) return sorted(filenames)
...@@ -132,7 +138,7 @@ def _convert_dataset(dataset_split): ...@@ -132,7 +138,7 @@ def _convert_dataset(dataset_split):
"""Converts the specified dataset split to TFRecord format. """Converts the specified dataset split to TFRecord format.
Args: Args:
dataset_split: The dataset split (e.g., train, val). dataset_split: The dataset split (e.g., train_fine, val_fine).
Raises: Raises:
RuntimeError: If loaded image and label have different shape, or if the RuntimeError: If loaded image and label have different shape, or if the
...@@ -142,8 +148,12 @@ def _convert_dataset(dataset_split): ...@@ -142,8 +148,12 @@ def _convert_dataset(dataset_split):
label_files = _get_files('label', dataset_split) label_files = _get_files('label', dataset_split)
num_images = len(image_files) num_images = len(image_files)
num_labels = len(label_files)
num_per_shard = int(math.ceil(num_images / _NUM_SHARDS)) num_per_shard = int(math.ceil(num_images / _NUM_SHARDS))
if num_images != num_labels:
raise RuntimeError("The number of images and labels doesn't match: {} {}".format(num_images, num_labels))
image_reader = build_data.ImageReader('png', channels=3) image_reader = build_data.ImageReader('png', channels=3)
label_reader = build_data.ImageReader('png', channels=1) label_reader = build_data.ImageReader('png', channels=1)
...@@ -179,8 +189,8 @@ def _convert_dataset(dataset_split): ...@@ -179,8 +189,8 @@ def _convert_dataset(dataset_split):
def main(unused_argv): def main(unused_argv):
# Only support converting 'train' and 'val' sets for now. # Only support converting 'train_fine', 'val_fine' and 'test_fine' sets for now.
for dataset_split in ['train', 'val']: for dataset_split in ['train_fine', 'val_fine', 'test_fine']:
_convert_dataset(dataset_split) _convert_dataset(dataset_split)
......
...@@ -42,6 +42,8 @@ WORK_DIR="." ...@@ -42,6 +42,8 @@ WORK_DIR="."
# Root path for Cityscapes dataset. # Root path for Cityscapes dataset.
CITYSCAPES_ROOT="${WORK_DIR}/cityscapes" CITYSCAPES_ROOT="${WORK_DIR}/cityscapes"
export PYTHONPATH="${CITYSCAPES_ROOT}:${PYTHONPATH}"
# Create training labels. # Create training labels.
python "${CITYSCAPES_ROOT}/cityscapesscripts/preparation/createTrainIdLabelImgs.py" python "${CITYSCAPES_ROOT}/cityscapesscripts/preparation/createTrainIdLabelImgs.py"
......
...@@ -81,8 +81,8 @@ DatasetDescriptor = collections.namedtuple( ...@@ -81,8 +81,8 @@ DatasetDescriptor = collections.namedtuple(
_CITYSCAPES_INFORMATION = DatasetDescriptor( _CITYSCAPES_INFORMATION = DatasetDescriptor(
splits_to_sizes={ splits_to_sizes={
'train': 2975, 'train_fine': 2975,
'val': 500, 'val_fine': 500,
}, },
num_classes=19, num_classes=19,
ignore_label=255, ignore_label=255,
......
...@@ -43,7 +43,7 @@ A local training job using `xception_65` can be run with the following command: ...@@ -43,7 +43,7 @@ A local training job using `xception_65` can be run with the following command:
python deeplab/train.py \ python deeplab/train.py \
--logtostderr \ --logtostderr \
--training_number_of_steps=90000 \ --training_number_of_steps=90000 \
--train_split="train" \ --train_split="train_fine" \
--model_variant="xception_65" \ --model_variant="xception_65" \
--atrous_rates=6 \ --atrous_rates=6 \
--atrous_rates=12 \ --atrous_rates=12 \
...@@ -95,7 +95,7 @@ command: ...@@ -95,7 +95,7 @@ command:
# From tensorflow/models/research/ # From tensorflow/models/research/
python deeplab/eval.py \ python deeplab/eval.py \
--logtostderr \ --logtostderr \
--eval_split="val" \ --eval_split="val_fine" \
--model_variant="xception_65" \ --model_variant="xception_65" \
--atrous_rates=6 \ --atrous_rates=6 \
--atrous_rates=12 \ --atrous_rates=12 \
...@@ -121,7 +121,7 @@ command: ...@@ -121,7 +121,7 @@ command:
# From tensorflow/models/research/ # From tensorflow/models/research/
python deeplab/vis.py \ python deeplab/vis.py \
--logtostderr \ --logtostderr \
--vis_split="val" \ --vis_split="val_fine" \
--model_variant="xception_65" \ --model_variant="xception_65" \
--atrous_rates=6 \ --atrous_rates=6 \
--atrous_rates=12 \ --atrous_rates=12 \
......
...@@ -68,6 +68,6 @@ Quick running the whole code on the PASCAL VOC 2012 dataset: ...@@ -68,6 +68,6 @@ Quick running the whole code on the PASCAL VOC 2012 dataset:
```bash ```bash
# From tensorflow/models/research/deeplab # From tensorflow/models/research/deeplab
sh local_test.sh bash local_test.sh
``` ```
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
# #
# Usage: # Usage:
# # From the tensorflow/models/research/deeplab directory. # # From the tensorflow/models/research/deeplab directory.
# sh ./local_test.sh # bash ./local_test.sh
# #
# #
...@@ -42,7 +42,7 @@ python "${WORK_DIR}"/model_test.py ...@@ -42,7 +42,7 @@ python "${WORK_DIR}"/model_test.py
# Go to datasets folder and download PASCAL VOC 2012 segmentation dataset. # Go to datasets folder and download PASCAL VOC 2012 segmentation dataset.
DATASET_DIR="datasets" DATASET_DIR="datasets"
cd "${WORK_DIR}/${DATASET_DIR}" cd "${WORK_DIR}/${DATASET_DIR}"
sh download_and_convert_voc2012.sh bash download_and_convert_voc2012.sh
# Go back to original directory. # Go back to original directory.
cd "${CURRENT_DIR}" cd "${CURRENT_DIR}"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment