Unverified Commit b860406a authored by Ruslan Baratov's avatar Ruslan Baratov Committed by GitHub
Browse files

DeepLab: Fix generation of tfrecord for Cityscapes (#8866)

* convert_cityscapes.sh: Update PYTHONPATH

Fix error `ModuleNotFoundError: No module named 'cityscapesscripts'`

* Check the number of labels and images

* DeepLab: Fix generation of tfrecord for Cityscapes
parent 73a911c0
...@@ -142,13 +142,17 @@ def _convert_dataset(dataset_split): ...@@ -142,13 +142,17 @@ 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)
for shard_id in range(_NUM_SHARDS): for shard_id in range(_NUM_SHARDS):
shard_filename = '%s-%05d-of-%05d.tfrecord' % ( shard_filename = '%s_fine-%05d-of-%05d.tfrecord' % (
dataset_split, shard_id, _NUM_SHARDS) dataset_split, shard_id, _NUM_SHARDS)
output_filename = os.path.join(FLAGS.output_dir, shard_filename) output_filename = os.path.join(FLAGS.output_dir, shard_filename)
with tf.python_io.TFRecordWriter(output_filename) as tfrecord_writer: with tf.python_io.TFRecordWriter(output_filename) as tfrecord_writer:
......
...@@ -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 \
......
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