基于Python的身份证验证识别和数据处理详解


Posted in Python onNovember 14, 2020

根据GB11643-1999公民身份证号码是特征组合码,由十七位数字本体码和一位数字校验码组成,排列顺序从左至右依次为:

六位数字地址码八位数字出生日期码三位数字顺序码一位数字校验码(数字10用罗马X表示)

基于Python的身份证验证识别和数据处理详解

校验系统:

校验码采用ISO7064:1983,MOD11-2校验码系统(图为校验规则样例)

用身份证号的前17位的每一位号码字符值分别乘上对应的加权因子值,得到的结果求和后对11进行取余,最后的结果放到表2检验码字符值..换算关系表中得出最后的一位身份证号码

基于Python的身份证验证识别和数据处理详解

基于Python的身份证验证识别和数据处理详解

代码:

# 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)

到此这篇关于基于Python的身份证验证识别和数据处理详解的文章就介绍到这了,更多相关python 身份验证识别内容请搜索三水点靠木以前的文章或继续浏览下面的相关文章希望大家以后多多支持三水点靠木!

Python 相关文章推荐
Python使用jsonpath-rw模块处理Json对象操作示例
Jul 31 Python
用Python编写一个简单的CS架构后门的方法
Nov 20 Python
Python3.5实现的三级菜单功能示例
Mar 25 Python
Python获取基金网站网页内容、使用BeautifulSoup库分析html操作示例
Jun 04 Python
Python使用numpy模块实现矩阵和列表的连接操作方法
Jun 26 Python
python获取点击的坐标画图形的方法
Jul 09 Python
Python企业编码生成系统之系统主要函数设计详解
Jul 26 Python
Numpy的简单用法小结
Aug 28 Python
python实现在多维数组中挑选符合条件的全部元素
Nov 26 Python
Python图片的横坐标汉字实例
Dec 04 Python
Python绘制全球疫情变化地图的实例代码
Apr 20 Python
Python 微信公众号文章爬取的示例代码
Nov 30 Python
Python join()函数原理及使用方法
Nov 14 #Python
详解pycharm连接远程linux服务器的虚拟环境的方法
Nov 13 #Python
利用python 下载bilibili视频
Nov 13 #Python
详解python polyscope库的安装和例程
Nov 13 #Python
python中的测试框架
Nov 13 #Python
Python加载数据的5种不同方式(收藏)
Nov 13 #Python
使用Python解析Chrome浏览器书签的示例
Nov 13 #Python
You might like
php5 pdo新改动加载注意事项
2008/09/11 PHP
PHP伪静态Rewrite设置之APACHE篇
2014/07/30 PHP
PHP观察者模式实例分析【对比JS观察者模式】
2019/05/22 PHP
IE8下Jquery获取select选中的值post到后台报错问题
2014/07/02 Javascript
node.js操作mongodb学习小结
2015/04/25 Javascript
js网页滚动条滚动事件实例分析
2015/05/05 Javascript
jQuery中$.ajax()和$.getJson()同步处理详解
2015/08/12 Javascript
详解JavaScript异步编程中jQuery的promise对象的作用
2016/05/03 Javascript
Bootstrap Paginator分页插件与ajax相结合实现动态无刷新分页效果
2016/05/27 Javascript
用JavaScript获取页面文档内容的实现代码
2016/06/10 Javascript
JS+HTML5手机开发之滚动和惯性缓动实现方法分析
2016/06/12 Javascript
JS给Array添加是否包含字符串的简单方法
2016/10/29 Javascript
微信小程序实现图片预览功能
2018/01/31 Javascript
基于vue-ssr的静态网站生成器VuePress 初体验
2018/04/17 Javascript
vue-cli项目代理proxyTable配置exclude的方法
2018/09/20 Javascript
详解微信图片防盗链“此图片来自微信公众平台 未经允许不得引用”的解决方案
2019/04/04 Javascript
layuiAdmin循环遍历展示商品图片列表的方法
2019/09/16 Javascript
Python和php通信乱码问题解决方法
2014/04/15 Python
Python八大常见排序算法定义、实现及时间消耗效率分析
2018/04/27 Python
Python3.6基于正则实现的计算器示例【无优化简单注释版】
2018/06/14 Python
Python List cmp()知识点总结
2019/02/18 Python
python发送多人邮件没有展示收件人问题的解决方法
2019/06/21 Python
python调试神器PySnooper的使用
2019/07/03 Python
python实现银行管理系统
2019/10/25 Python
使用python切片实现二维数组复制示例
2019/11/26 Python
python 回溯法模板详解
2020/02/26 Python
编写用C语言实现的求n阶阶乘问题的递归算法
2014/10/21 面试题
生日邀请函范文
2014/01/13 职场文书
九年级政治教学反思
2014/02/06 职场文书
农村面貌改造提升实施方案
2014/03/18 职场文书
团日活动总结
2014/04/28 职场文书
2014年自愿离婚协议书
2014/10/10 职场文书
建议书范文
2015/02/05 职场文书
小程序后台PHP版本部署运行 LNMP+WNMP
2021/04/01 Servers
pytorch 一行代码查看网络参数总量的实现
2021/05/12 Python
JavaScript parseInt0.0000005打印5原理解析
2022/07/23 Javascript