"git@developer.sourcefind.cn:OpenDAS/fastmoe.git" did not exist on "5e9bb2e9e9b69f84037d04e93846b2ace69fc1f7"
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 ...@@ -26,17 +26,17 @@ from PIL import Image
import tensorflow as tf import tensorflow as tf
FLAGS = tf.app.flags.FLAGS FLAGS = tf.compat.v1.flags.FLAGS
tf.app.flags.DEFINE_string('original_gt_folder', tf.compat.v1.flags.DEFINE_string('original_gt_folder',
'./VOCdevkit/VOC2012/SegmentationClass', './VOCdevkit/VOC2012/SegmentationClass',
'Original ground truth annotations.') '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', tf.compat.v1.flags.DEFINE_string('output_dir',
'./VOCdevkit/VOC2012/SegmentationClassRaw', './VOCdevkit/VOC2012/SegmentationClassRaw',
'folder to save modified ground truth annotations.') 'folder to save modified ground truth annotations.')
def _remove_colormap(filename): def _remove_colormap(filename):
...@@ -59,14 +59,14 @@ def _save_annotation(annotation, filename): ...@@ -59,14 +59,14 @@ def _save_annotation(annotation, filename):
filename: Output filename. filename: Output filename.
""" """
pil_image = Image.fromarray(annotation.astype(dtype=np.uint8)) 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') pil_image.save(f, 'PNG')
def main(unused_argv): def main(unused_argv):
# Create the output directory if not exists. # Create the output directory if not exists.
if not tf.gfile.IsDirectory(FLAGS.output_dir): if not tf.io.gfile.isdir(FLAGS.output_dir):
tf.gfile.MakeDirs(FLAGS.output_dir) tf.io.gfile.makedirs(FLAGS.output_dir)
annotations = glob.glob(os.path.join(FLAGS.original_gt_folder, annotations = glob.glob(os.path.join(FLAGS.original_gt_folder,
'*.' + FLAGS.segmentation_format)) '*.' + FLAGS.segmentation_format))
...@@ -80,4 +80,4 @@ def main(unused_argv): ...@@ -80,4 +80,4 @@ def main(unused_argv):
if __name__ == '__main__': 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