資源簡介
語義圖像分割模型deeplab-v3的tensorflow源代碼,歡迎下載

代碼片段和文件信息
“““Converts?PASCAL?dataset?to?TFRecords?file?format.“““
from?__future__?import?absolute_import
from?__future__?import?division
from?__future__?import?print_function
import?argparse
import?io
import?os
import?sys
import?PIL.Image
import?tensorflow?as?tf
from?utils?import?dataset_util
parser?=?argparse.ArgumentParser()
parser.add_argument(‘--data_dir‘?type=str?default=‘./dataset/VOCdevkit/VOC2012‘
????????????????????help=‘Path?to?the?directory?containing?the?PASCAL?VOC?data.‘)
parser.add_argument(‘--output_path‘?type=str?default=‘./dataset‘
????????????????????help=‘Path?to?the?directory?to?create?TFRecords?outputs.‘)
parser.add_argument(‘--train_data_list‘?type=str?default=‘./dataset/train.txt‘
????????????????????help=‘Path?to?the?file?listing?the?training?data.‘)
parser.add_argument(‘--valid_data_list‘?type=str?default=‘./dataset/val.txt‘
????????????????????help=‘Path?to?the?file?listing?the?validation?data.‘)
parser.add_argument(‘--image_data_dir‘?type=str?default=‘JPEGImages‘
????????????????????help=‘The?directory?containing?the?image?data.‘)
parser.add_argument(‘--label_data_dir‘?type=str?default=‘SegmentationClassAug‘
????????????????????help=‘The?directory?containing?the?augmented?label?data.‘)
def?dict_to_tf_example(image_path
???????????????????????label_path):
??“““Convert?image?and?label?to?tf.Example?proto.
??Args:
????image_path:?Path?to?a?single?PASCAL?image.
????label_path:?Path?to?its?corresponding?label.
??Returns:
????example:?The?converted?tf.Example.
??Raises:
????ValueError:?if?the?image?pointed?to?by?image_path?is?not?a?valid?JPEG?or
????????????????if?the?label?pointed?to?by?label_path?is?not?a?valid?PNG?or
????????????????if?the?size?of?image?does?not?match?with?that?of?label.
??“““
??with?tf.gfile.GFile(image_path?‘rb‘)?as?fid:
????encoded_jpg?=?fid.read()
??encoded_jpg_io?=?io.BytesIO(encoded_jpg)
??image?=?PIL.Image.open(encoded_jpg_io)
??if?image.format?!=?‘JPEG‘:
????raise?ValueError(‘Image?format?not?JPEG‘)
??with?tf.gfile.GFile(label_path?‘rb‘)?as?fid:
????encoded_label?=?fid.read()
??encoded_label_io?=?io.BytesIO(encoded_label)
??label?=?PIL.Image.open(encoded_label_io)
??if?label.format?!=?‘PNG‘:
????raise?ValueError(‘Label?format?not?PNG‘)
??if?image.size?!=?label.size:
????raise?ValueError(‘The?size?of?image?does?not?match?with?that?of?label.‘)
??width?height?=?image.size
??example?=?tf.train.Example(features=tf.train.Features(feature={
????‘image/height‘:?dataset_util.int64_feature(height)
????‘image/width‘:?dataset_util.int64_feature(width)
????‘image/encoded‘:?dataset_util.bytes_feature(encoded_jpg)
????‘image/format‘:?dataset_util.bytes_feature(‘jpeg‘.encode(‘utf8‘))
????‘label/encoded‘:?dataset_util.bytes_feature(encoded_label)
????‘label/format‘:?dataset_util.bytes_feature(‘png‘.encode(‘utf8‘))
??}))
??return?example
def?create_tf_record(output_filename
?????????????????????image_dir
?????????????????????label_dir
?????????????????????examples):
??“““C
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-04-30?06:51??tensorflow-deeplab-v3-plus-master\
?????文件????????1299??2018-04-30?06:51??tensorflow-deeplab-v3-plus-master\.gitignore
?????文件????????1070??2018-04-30?06:51??tensorflow-deeplab-v3-plus-master\LICENSE
?????文件????????5024??2018-04-30?06:51??tensorflow-deeplab-v3-plus-master\README.md
?????文件????????5256??2018-04-30?06:51??tensorflow-deeplab-v3-plus-master\create_pascal_tf_record.py
?????目錄???????????0??2018-04-30?06:51??tensorflow-deeplab-v3-plus-master\dataset\
?????文件?????????127??2018-04-30?06:51??tensorflow-deeplab-v3-plus-master\dataset\sample_images_list.txt
?????文件???????17472??2018-04-30?06:51??tensorflow-deeplab-v3-plus-master\dataset\test.txt
?????文件??????126984??2018-04-30?06:51??tensorflow-deeplab-v3-plus-master\dataset\train.txt
?????文件???????17388??2018-04-30?06:51??tensorflow-deeplab-v3-plus-master\dataset\val.txt
?????文件???????14710??2018-04-30?06:51??tensorflow-deeplab-v3-plus-master\deeplab_model.py
?????文件????????5299??2018-04-30?06:51??tensorflow-deeplab-v3-plus-master\evaluate.py
?????文件????????2382??2018-04-30?06:51??tensorflow-deeplab-v3-plus-master\export_inference_graph.py
?????目錄???????????0??2018-04-30?06:51??tensorflow-deeplab-v3-plus-master\images\
?????文件??????198096??2018-04-30?06:51??tensorflow-deeplab-v3-plus-master\images\tensorboard_images.png
?????文件??????136959??2018-04-30?06:51??tensorflow-deeplab-v3-plus-master\images\tensorboard_miou.png
?????文件????????3529??2018-04-30?06:51??tensorflow-deeplab-v3-plus-master\inference.py
?????文件???????10494??2018-04-30?06:51??tensorflow-deeplab-v3-plus-master\train.py
?????目錄???????????0??2018-04-30?06:51??tensorflow-deeplab-v3-plus-master\utils\
?????文件???????????0??2018-04-30?06:51??tensorflow-deeplab-v3-plus-master\utils\__init__.py
?????文件????????4950??2018-04-30?06:51??tensorflow-deeplab-v3-plus-master\utils\dataset_util.py
?????文件????????9308??2018-04-30?06:51??tensorflow-deeplab-v3-plus-master\utils\preprocessing.py
- 上一篇:反激式變換器的系統設計
- 下一篇:華工操作系統課程設計
評論
共有 條評論