Closed KienVu2368 closed 6 years ago
you can change 'parameters = params.get('Params')' to 'parameters = params' on model.py when you export
@JcmeLs I got another error after edit model.py
Traceback (most recent call last):
File "export_model.py", line 45, in <module>
serving_input_receiver_fn=preprocess_image_for_prediction(min_width=10))
File "/home/dg/anaconda3/lib/python3.6/site-packages/tensorflow/python/estimator/estimator.py", line 525, in export_savedmodel
export_dir = get_timestamped_export_dir(export_dir_base)
File "/home/dg/anaconda3/lib/python3.6/site-packages/tensorflow/python/estimator/export/export.py", line 257, in get_timestamped_export_dir
compat.as_bytes(export_dir_base),
File "/home/dg/anaconda3/lib/python3.6/site-packages/tensorflow/python/util/compat.py", line 65, in as_bytes
(bytes_or_text,))
TypeError: Expected binary or unicode string, got None
Do you know how to fix it?
TensorFlow version=1.3?
'Params' object has no attribute 'get' ,this problem you can only change export.py, not need change model.py.
code:params_json = import_params_from_json(args.get('model_dir'))
params = Params(**params_json)
model_params = {
'Params': params,
}
est_config = tf.estimator.RunConfig()
est_config.replace(keep_checkpoint_max=10,
save_checkpoints_steps=params.save_interval,
session_config=config_sess,
save_checkpoints_secs=None,
save_summary_steps=1000)
estimator = tf.estimator.Estimator(model_fn=crnn_fn, params=model_params,
model_dir=args.get('model_dir'),
config=est_config,
)
@JcmeLs correct me if Im wrong. I edited file export_model.py from
# Import parameters from the json file
params_json = import_params_from_json(args.get('model_dir'))
params = Params(**params_json)
# Config
est_config = tf.estimator.RunConfig()
est_config.replace(keep_checkpoint_max=10,
save_checkpoints_steps=params.save_interval,
session_config=config_sess,
save_checkpoints_secs=None,
save_summary_steps=1000)
estimator = tf.estimator.Estimator(model_fn=crnn_fn, params=params,
model_dir=args.get('model_dir'),
config=est_config,
)
to
params_json = import_params_from_json(args.get('model_dir'))
params = Params(**params_json)
model_params = {
'Params': params,
}
# Config
est_config = tf.estimator.RunConfig()
est_config.replace(keep_checkpoint_max=10,
save_checkpoints_steps=params.save_interval,
session_config=config_sess,
save_checkpoints_secs=None,
save_summary_steps=1000)
estimator = tf.estimator.Estimator(model_fn=crnn_fn, params=model_params,
model_dir=args.get('model_dir'),
config=est_config,
)
and keep file model.py as original
But I got new error
Traceback (most recent call last):
File "export_model.py", line 45, in <module>
serving_input_receiver_fn=preprocess_image_for_prediction(min_width=10))
File "/home/dg/anaconda3/lib/python3.6/site-packages/tensorflow/python/estimator/estimator.py", line 525, in export_savedmodel
export_dir = get_timestamped_export_dir(export_dir_base)
File "/home/dg/anaconda3/lib/python3.6/site-packages/tensorflow/python/estimator/export/export.py", line 257, in get_timestamped_export_dir
compat.as_bytes(export_dir_base),
File "/home/dg/anaconda3/lib/python3.6/site-packages/tensorflow/python/util/compat.py", line 65, in as_bytes
(bytes_or_text,))
TypeError: Expected binary or unicode string, got None
I think because export_dir_base is None I run in Ubuntu 16 with cpu and tensorflow 1.3.
@KienVu2368 yes,just change estimator.export_savedmodel(args.get('export_dir'), serving_input_receiver_fn=preprocess_image_for_prediction(min_width=10))
to estimator.export_savedmodel(args.get('output_dir'), serving_input_receiver_fn=preprocess_image_for_prediction(min_width=10))
Thank you so much @JcmeLs :D
After trained model. I run python export_model.py and got error
I run in Ubuntu 16 with cpu and tensorflow 1.3. Please let me know if anyone has solved this.