Exemplo n.º 1
0
def _main():
    parser = _get_parser()
    args, unknown_args = parser.parse_known_args()
    temp_filename = uuid.uuid4().hex
    ir_args, unknown_args = _extract_ir_args(args, unknown_args, temp_filename)
    ret = convertToIR._convert(ir_args)
    if int(ret) != 0:
        _sys.exit(int(ret))
    if args.dstFramework != 'coreml':
        network_filename = get_network_filename(args.dstFramework,
                                                temp_filename,
                                                args.outputModel)
        code_args, unknown_args = _extract_code_args(args, unknown_args,
                                                     temp_filename,
                                                     network_filename)
        ret = IRToCode._convert(code_args)
        if int(ret) != 0:
            _sys.exit(int(ret))
        from mmdnn.conversion._script.dump_code import dump_code
        dump_code(args.dstFramework, network_filename + '.py',
                  temp_filename + '.npy', args.outputModel, args.dump_tag)
        #remove_temp_files(temp_filename)

    else:
        model_args, unknown_args = _extract_model_args(args, unknown_args,
                                                       temp_filename)
        ret = IRToModel._convert(model_args)
        #remove_temp_files(temp_filename)
        _sys.exit(int(ret))
Exemplo n.º 2
0
def _main():
    parser = _get_parser()
    args, unknown_args = parser.parse_known_args()
    temp_filename = uuid.uuid4().hex
    ir_args, unknown_args = _extract_ir_args(args, unknown_args, temp_filename)
    ret = convertToIR._convert(ir_args)
    if int(ret) != 0:
        _sys.exit(int(ret))
    if args.dstFramework != 'coreml':
        code_args, unknown_args = _extract_code_args(args, unknown_args, temp_filename)
        ret = IRToCode._convert(code_args)
        if int(ret) != 0:
            _sys.exit(int(ret))
        from mmdnn.conversion._script.dump_code import dump_code
        dump_code(args.dstFramework, temp_filename + '.py', temp_filename + '.npy', args.outputModel)
        remove_temp_files(temp_filename)

    elif args.dstType == 'model':
        model_args, unknown_args = _extract_model_args(args, unknown_args, temp_filename)
        ret = IRToModel._convert(model_args)
        remove_temp_files(temp_filename)
        _sys.exit(int(ret))