def export(context, model, output_path): """Convert a pytext model snapshot to a caffe2 model.""" config = parse_config(Mode.TRAIN, context.obj.load_config()) model = model or config.save_snapshot_path output_path = output_path or config.export_caffe2_path print(f"Exporting {model} to {output_path}") export_saved_model_to_caffe2(model, output_path)
def export(context, export_json, model, output_path, output_onnx_path): """Convert a pytext model snapshot to a caffe2 model.""" # only populate from export_json if no export option is configured from the command line. if export_json: if not output_path and not output_onnx_path: export_json_config = _load_and_validate_export_json_config( export_json) export_section_config = export_json_config["export"] if "export_caffe2_path" in export_section_config: output_path = export_section_config["export_caffe2_path"] if "export_onnx_path" in export_section_config: output_onnx_path = export_section_config["export_onnx_path"] else: print( "the export-json config is ignored because export options are found the command line" ) config = context.obj.load_config() export_list = config.export_list model = model or config.save_snapshot_path if len(export_list) == 0: output_path = output_path or config.export_caffe2_path output_onnx_path = output_onnx_path or config.export_onnx_path print( f"Exporting {model} to caffe2 file: {output_path} and onnx file: {output_onnx_path}" ) export_saved_model_to_caffe2(model, output_path, output_onnx_path) else: for idx in range(0, len(export_list)): output_path = output_path or config.get_export_caffe2_path(idx) output_onnx_path = output_onnx_path or config.get_export_onnx_path( idx) print( f"Exporting {model} to caffe2 file: {output_path} and onnx file: {output_onnx_path}" ) export_saved_model_to_caffe2(model, output_path, output_onnx_path)
def export(context, model, output_path, output_onnx_path): """Convert a pytext model snapshot to a caffe2 model.""" config = context.obj.load_config() model = model or config.save_snapshot_path output_path = output_path or config.export_caffe2_path output_onnx_path = output_onnx_path or config.export_onnx_path print( f"Exporting {model} to caffe2 file: {output_path} and onnx file: {output_onnx_path}" ) export_saved_model_to_caffe2(model, output_path, output_onnx_path)