Commit 92384c60 authored by Lotte1990's avatar Lotte1990 Committed by aquariusjay
Browse files

Make this file TensorFlow 2.0 compatible (#7836)

* Make this file TensorFlow 2.0 compatible

* Update remove_gt_colormap.py
parent 7e12e4f4
......@@ -26,17 +26,17 @@ from PIL import Image
import tensorflow as tf
FLAGS = tf.app.flags.FLAGS
FLAGS = tf.compat.v1.flags.FLAGS
tf.app.flags.DEFINE_string('original_gt_folder',
'./VOCdevkit/VOC2012/SegmentationClass',
'Original ground truth annotations.')
tf.compat.v1.flags.DEFINE_string('original_gt_folder',
'./VOCdevkit/VOC2012/SegmentationClass',
'Original ground truth annotations.')
tf.app.flags.DEFINE_string('segmentation_format', 'png', 'Segmentation format.')
tf.compat.v1.flags.DEFINE_string('segmentation_format', 'png', 'Segmentation format.')
tf.app.flags.DEFINE_string('output_dir',
'./VOCdevkit/VOC2012/SegmentationClassRaw',
'folder to save modified ground truth annotations.')
tf.compat.v1.flags.DEFINE_string('output_dir',
'./VOCdevkit/VOC2012/SegmentationClassRaw',
'folder to save modified ground truth annotations.')
def _remove_colormap(filename):
......@@ -59,14 +59,14 @@ def _save_annotation(annotation, filename):
filename: Output filename.
"""
pil_image = Image.fromarray(annotation.astype(dtype=np.uint8))
with tf.gfile.Open(filename, mode='w') as f:
with tf.io.gfile.GFile(filename, mode='w') as f:
pil_image.save(f, 'PNG')
def main(unused_argv):
# Create the output directory if not exists.
if not tf.gfile.IsDirectory(FLAGS.output_dir):
tf.gfile.MakeDirs(FLAGS.output_dir)
if not tf.io.gfile.isdir(FLAGS.output_dir):
tf.io.gfile.makedirs(FLAGS.output_dir)
annotations = glob.glob(os.path.join(FLAGS.original_gt_folder,
'*.' + FLAGS.segmentation_format))
......@@ -80,4 +80,4 @@ def main(unused_argv):
if __name__ == '__main__':
tf.app.run()
tf.compat.v1.app.run()
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