|
|
@ -23,23 +23,23 @@ from paddle.v2.topology import Topology
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def merge_v2_model(net, param_file, output_file):
|
|
|
|
def merge_v2_model(net, param_file, output_file):
|
|
|
|
'''Integrate the model config and model parameters into one file.
|
|
|
|
'''Merge the model config and parameters into one file.
|
|
|
|
|
|
|
|
|
|
|
|
The model configuration file describes the model structure which
|
|
|
|
The model configuration file describes the model structure which
|
|
|
|
ends with .py. The parameters file stores the parameters of the model
|
|
|
|
ends with .py. The parameters file stores the parameters of the model
|
|
|
|
which ends with .tar.gz.
|
|
|
|
which ends with .tar.gz.
|
|
|
|
|
|
|
|
|
|
|
|
@param net The output layer of the network.
|
|
|
|
@param net The output layer of the network for inference.
|
|
|
|
@param param_file Path of the model parameters(.tar.gz) which is stored by v2 api.
|
|
|
|
@param param_file Path of the parameters (.tar.gz) which is stored by v2 api.
|
|
|
|
@param output_file Path of the merged file which will be generated.
|
|
|
|
@param output_file Path of the merged file which will be generated.
|
|
|
|
|
|
|
|
|
|
|
|
Usage:
|
|
|
|
Usage:
|
|
|
|
|
|
|
|
|
|
|
|
from paddle.util.merge_model import merge_v2_model
|
|
|
|
from paddle.utils.merge_model import merge_v2_model
|
|
|
|
# import your network configuration
|
|
|
|
# import your network configuration
|
|
|
|
from mobilenet import mobile_net
|
|
|
|
from example_net import net_conf
|
|
|
|
|
|
|
|
|
|
|
|
net = mobile_net(3*224*224, 102)
|
|
|
|
net = net_conf(is_predict=True)
|
|
|
|
param_file = './param_pass_00000.tar.gz'
|
|
|
|
param_file = './param_pass_00000.tar.gz'
|
|
|
|
output_file = './output.paddle'
|
|
|
|
output_file = './output.paddle'
|
|
|
|
|
|
|
|
|
|
|
@ -48,7 +48,7 @@ def merge_v2_model(net, param_file, output_file):
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
|
assert isinstance(net, LayerOutput), \
|
|
|
|
assert isinstance(net, LayerOutput), \
|
|
|
|
"The net should be the output of the network"
|
|
|
|
"The net should be the output of the network for inference"
|
|
|
|
assert os.path.exists(param_file), \
|
|
|
|
assert os.path.exists(param_file), \
|
|
|
|
"The model parameters file %s does not exists " % (param_file)
|
|
|
|
"The model parameters file %s does not exists " % (param_file)
|
|
|
|
|
|
|
|
|
|
|
|