- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
`i have a problem when i try to train the model(train.py)
INPUT:
python train.py --logtostderr --train_dir=training/ --pipeline_config_path=training/faster_rcnn_inception_v2_pets.config
代码: 导入函数工具 导入 json 导入操作系统 将 tensorflow 导入为 tf 导入系统 sys.path.append("C:\Users\Gilbertchristian\Documents\Anaconda\Object_detection_api\models\research") sys.path.append("C:\Users\Gilbertchristian\Documents\Anaconda\Object_detection_api\models\research\object_detection\utils") sys.path.append("C:\Users\Gilbertchristian\Documents\Anaconda\Object_detection_api\models\research\slim") sys.path.append("C:\Users\Gilbertchristian\Documents\Anaconda\Object_detection_api\models\research\slim\nets")
from object_detection.builders import dataset_builder
from object_detection.builders import graph_rewriter_builder
from object_detection.builders import model_builder
from object_detection.legacy import trainer
from object_detection.utils import config_util
tf.logging.set_verbosity(tf.logging.INFO)
flags = tf.app.flags
flags.DEFINE_string('master', '', 'Name of the TensorFlow master to use.')
flags.DEFINE_integer('task', 0, 'task id')
flags.DEFINE_integer('num_clones', 1, 'Number of clones to deploy per worker.')
flags.DEFINE_boolean('clone_on_cpu', False,
'Force clones to be deployed on CPU. Note that even if '
'set to False (allowing ops to run on gpu), some ops may '
'still be run on the CPU if they have no GPU kernel.')
flags.DEFINE_integer('worker_replicas', 1, 'Number of worker+trainer '
'replicas.')
flags.DEFINE_integer('ps_tasks', 0,
'Number of parameter server tasks. If None, does not use '
'a parameter server.')
flags.DEFINE_string('train_dir', '',
'Directory to save the checkpoints and training summaries.')
flags.DEFINE_string('pipeline_config_path', '',
'Path to a pipeline_pb2.TrainEvalPipelineConfig config '
'file. If provided, other configs are ignored')
flags.DEFINE_string('train_config_path', '',
'Path to a train_pb2.TrainConfig config file.')
flags.DEFINE_string('input_config_path', '',
'Path to an input_reader_pb2.InputReader config file.')
flags.DEFINE_string('model_config_path', '',
'Path to a model_pb2.DetectionModel config file.')
FLAGS = flags.FLAGS
@tf.contrib.framework.deprecated(None, 'Use object_detection/model_main.py.')
def main(_):
assert FLAGS.train_dir, '`train_dir` is missing.'
if FLAGS.task == 0: tf.gfile.MakeDirs(FLAGS.train_dir)
if FLAGS.pipeline_config_path:
configs = config_util.get_configs_from_pipeline_file(
FLAGS.pipeline_config_path)
if FLAGS.task == 0:
tf.gfile.Copy(FLAGS.pipeline_config_path,
os.path.join(FLAGS.train_dir, 'pipeline.config'),
overwrite=True)
else:
configs = config_util.get_configs_from_multiple_files(
model_config_path=FLAGS.model_config_path,
train_config_path=FLAGS.train_config_path,
train_input_config_path=FLAGS.input_config_path)
if FLAGS.task == 0:
for name, config in [('model.config', FLAGS.model_config_path),
('train.config', FLAGS.train_config_path),
('input.config', FLAGS.input_config_path)]:
tf.gfile.Copy(config, os.path.join(FLAGS.train_dir, name),
overwrite=True)
model_config = configs['model']
train_config = configs['train_config']
input_config = configs['train_input_config']
model_fn = functools.partial(
model_builder.build,
model_config=model_config,
is_training=True)
def get_next(config):
return dataset_builder.make_initializable_iterator(
dataset_builder.build(config)).get_next()
create_input_dict_fn = functools.partial(get_next, input_config)
env = json.loads(os.environ.get('TF_CONFIG', '{}'))
cluster_data = env.get('cluster', None)
cluster = tf.train.ClusterSpec(cluster_data) if cluster_data else None
task_data = env.get('task', None) or {'type': 'master', 'index': 0}
task_info = type('TaskSpec', (object,), task_data)
# Parameters for a single worker.
ps_tasks = 0
worker_replicas = 1
worker_job_name = 'lonely_worker'
task = 0
is_chief = True
master = ''
if cluster_data and 'worker' in cluster_data:
# Number of total worker replicas include "worker"s and the "master".
worker_replicas = len(cluster_data['worker']) + 1
if cluster_data and 'ps' in cluster_data:
ps_tasks = len(cluster_data['ps'])
if worker_replicas > 1 and ps_tasks < 1:
raise ValueError('At least 1 ps task is needed for distributed training.')
if worker_replicas >= 1 and ps_tasks > 0:
# Set up distributed training.
server = tf.train.Server(tf.train.ClusterSpec(cluster), protocol='grpc',
job_name=task_info.type,
task_index=task_info.index)
if task_info.type == 'ps':
server.join()
return
worker_job_name = '%s/task:%d' % (task_info.type, task_info.index)
task = task_info.index
is_chief = (task_info.type == 'master')
master = server.target
graph_rewriter_fn = None
if 'graph_rewriter_config' in configs:
graph_rewriter_fn = graph_rewriter_builder.build(
configs['graph_rewriter_config'], is_training=True)
trainer.train(
create_input_dict_fn,
model_fn,
train_config,
master,
task,
FLAGS.num_clones,
worker_replicas,
FLAGS.clone_on_cpu,
ps_tasks,
worker_job_name,
is_chief,
FLAGS.train_dir,
graph_hook_fn=graph_rewriter_fn()
if __name__ == '__main__':
tf.app.run()
输出: 文件“train.py”,第 191 行,位于 tf.app.run() 文件“C:\Users\Gilbertchristian\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\platform\app.py”,第 125 行,运行中 _sys.exit(主(argv)) 文件“C:\Users\Gilbertchristian\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\util\deprecation.py”,第 324 行,在 new_func 中 返回 func(*args, **kwargs) 文件“train.py”,第 187 行,在 main 中 graph_hook_fn=graph_rewriter_fn) 文件“C:\Users\Gilbertchristian\AppData\Local\Programs\Python\Python35\lib\site-packages\object_detection-0.1-py3.5.egg\object_detection\legacy\trainer.py”,第 280 行,训练中 train_config.prefetch_queue_capacity,data_augmentation_options) 文件“C:\Users\Gilbertchristian\AppData\Local\Programs\Python\Python35\lib\site-packages\object_detection-0.1-py3.5.egg\object_detection\legacy\trainer.py”,第 59 行,在 create_input_queue 中 张量字典 = create_tensor_dict_fn() 文件“train.py”,第 128 行,在 get_next 中 dataset_builder.build(config)).get_next() 文件“C:\Users\Gilbertchristian\AppData\Local\Programs\Python\Python35\lib\site-packages\object_detection-0.1-py3.5.egg\object_detection\builders\dataset_builder.py”,第 120 行,在构建中 load_multiclass_scores=input_reader_config.load_multiclass_scores, 属性错误:load_multiclass_scores
最佳答案
文件/tensorflow/models/research/object_detection/protos/input_reader_pb2.py
是否包含name='load_multiclass_scores'
如果没有,重新运行可能会有所帮助./bin/protoc object_detection/protos/*.proto --python_out=.
(可能有不同的版本)
关于python - 如何修复这个 "attribute error,:load_multiclass_scores"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55731460/
`i have a problem when i try to train the model(train.py) INPUT: python train.py --logtostde
我是一名优秀的程序员,十分优秀!