实习中用到,记录一下:
首先下载retrain.py文件,下载地址https://github.com/tensorflow/tensorflow/tree/r1.1
根据自己的tf版本选择branch
retrain.py的路径在tensorflow-examples-image_retraining-retrain.py
打开retrain.py设置一些参数
parser.add_argument(
'--image_dir',
type=str,
default='/home/user/inception_v3_retrain/train/',
help='Path to folders of labeled images.'
)
parser.add_argument(
'--output_graph',
type=str,
default='/home/user/inception_v3_retrain/tmp/output_graph.pb',
help='Where to save the trained graph.'
parser.add_argument(
'--output_labels',
type=str,
default='/home/user/inception_v3_retrain/tmp/output_labels.txt',
help='Where to save the trained graph\'s labels.'
)
parser.add_argument(
'--model_dir',
type=str,
default='/home/user/inception_v3_retrain/tmp/imagenet',
help="""\
Path to classify_image_graph_def.pb,
imagenet_synset_to_human_label_map.txt, and
imagenet_2012_challenge_label_map_proto.pbtxt.\
"""
)
parser.add_argument(
'--bottleneck_dir',
type=str,
default='/home/user/inception_v3_retrain/tmp/bottleneck',
help='Path to cache bottleneck layer values as files.'
)
只需要将训练数据按类别存放在不同的子文件夹,并将这些子文件夹存放在一个文件夹中,运行retrain.py