基于Python的身份证验证识别和数据处理详解
作者:郎志刚 发布时间:2021-04-22 04:43:09
标签:python,身份验证识别,数据处理
根据GB11643-1999公民身份证号码是特征组合码,由十七位数字本体码和一位数字校验码组成,排列顺序从左至右依次为:
六位数字地址码八位数字出生日期码三位数字顺序码一位数字校验码(数字10用罗马X表示)
校验系统:
校验码采用ISO7064:1983,MOD11-2校验码系统(图为校验规则样例)
用身份证号的前17位的每一位号码字符值分别乘上对应的加权因子值,得到的结果求和后对11进行取余,最后的结果放到表2检验码字符值..换算关系表中得出最后的一位身份证号码
代码:
# coding=utf-8
# Copyright 2018 The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Convert BERT checkpoint."""
import argparse
import torch
from transformers import BertConfig, BertForPreTraining, load_tf_weights_in_bert
from transformers.utils import logging
logging.set_verbosity_info()
def convert_tf_checkpoint_to_pytorch(tf_checkpoint_path, bert_config_file, pytorch_dump_path):
# Initialise PyTorch model
config = BertConfig.from_json_file(bert_config_file)
print("Building PyTorch model from configuration: {}".format(str(config)))
model = BertForPreTraining(config)
# Load weights from tf checkpoint
load_tf_weights_in_bert(model, config, tf_checkpoint_path)
# Save pytorch-model
print("Save PyTorch model to {}".format(pytorch_dump_path))
torch.save(model.state_dict(), pytorch_dump_path)
if __name__ == "__main__":
parser = argparse.ArgumentParser()
# Required parameters
parser.add_argument(
"--tf_checkpoint_path", default=None, type=str, required=True, help="Path to the TensorFlow checkpoint path."
)
parser.add_argument(
"--bert_config_file",
default=None,
type=str,
required=True,
help="The config json file corresponding to the pre-trained BERT model. \n"
"This specifies the model architecture.",
)
parser.add_argument(
"--pytorch_dump_path", default=None, type=str, required=True, help="Path to the output PyTorch model."
)
args = parser.parse_args()
convert_tf_checkpoint_to_pytorch(args.tf_checkpoint_path, args.bert_config_file, args.pytorch_dump_path)
来源:https://www.cnblogs.com/langzhig/archive/2020/11/13/13969958.html
0
投稿
猜你喜欢
- 用于匹配的正则表达式为 :([1-9]\d*\.?\d*)|(0\.\d*[1-9])([1-9] :匹配1~9的数字;\d :匹配数字,包
- 为了更好的理解这些基本操作,下面会通过读取一个股票数据,来进行Pandas基本数据操作的语法介绍。# 读取文件(读取保存文件后面会专门进行讲
- This is a {t}. {name}是一个很强大的字符串模板解析方法。它接受三个参数,分别是{args.text},{args.obj
- 首先建一个access 数据库,库中有一个URLINDEX表,其中URL和Keywords字段分别添加了索引,如下:URL &nb
- 前序、中序和后序表达式是什么?对于像B∗C 这样的算术表达式,可以根据其形式来正确地运算。在B∗
- 基于Ubuntu16.04 + Python3 + nginx + mysql + Django接下来先安装这些必要的环境,这些操作都是在你
- numpy模块下的median作用为: 计算沿指定轴的中位数返回数组元素的中位数其函数接口为:median(a, axis=None, ou
- <?php/** * HOST: www.icbase.com *///set_time_limit(0);//
- 引言昨天把系分的项目又加了一点逻辑判断,比如已经下单的菜品不能减少,不能重复下单,应该先下单再支付等…弄完购物车的逻辑之后,发现一直没有管备
- 安装SDK:pip install baidu-aip如果在pycharm里也可以在setting----Project Interpret
- 这里要注意的是js的时间戳是13位,php的时间戳是10位,转换函数如下: var nowtime = (new Date).getTime
- 今天一个域名查询系统出现故障,该系统是用的ASP调用XMLHTTP获取whois库的数据,具体错误如下: msxml3.dll 错
- 很多人错误地认为ASP是简单、低效的代名词,认为ASP是低能的,不足挂齿的,也很简单,一学就会,一琢磨就精通。有人讲ASP不安全,写ASP的
- 今天我们来学习字符串数据类型相关知识,将讨论如何声明字符串数据类型,字符串数据类型与 ASCII 表的关系,字符串数据类型的属性,以及一些重
- Python入门教程FROM:http://www.cnblogs.com/taowen/articles/11239.aspx作者:tao
- 先看几个数据。。一大堆文字滴,不管人家是不是故意的,字数还是这样:news.163.cn:14px,39个中文字符 news.sina.co
- 我就废话不多说了,大家还是直接看代码吧!file1 = 'C:\\Users\\Administrator\\Desktop\\te
- 0 引言前段时间找到了一个免费的天气预报API,费了好段时间把这个API解析并组装成自己想用的格式了,就想着如何实现每天发送天气信息给自己。
- 见下表:序号保留字序号保留字序号保留字1ADD80ESCAPE159OR2ABSOLUTE81EXCEPT160ORDER3ACTION82
- 熬了半个通宵,写出了自己的Google SiteMap文件,在这里给出详细编写教程,愿对大家有所帮助。Google SiteMap的作用及协