基于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 相关文章推荐
2018年Python值得关注的开源库、工具和开发者(总结篇)
Jan 04 Python
Python使用matplotlib实现的图像读取、切割裁剪功能示例
Apr 28 Python
用python脚本24小时刷浏览器的访问量方法
Dec 07 Python
python 随机森林算法及其优化详解
Jul 11 Python
对Python生成器、装饰器、递归的使用详解
Jul 19 Python
基于django ManyToMany 使用的注意事项详解
Aug 09 Python
Python开发企业微信机器人每天定时发消息实例
Mar 17 Python
python 爬虫如何正确的使用cookie
Oct 27 Python
python进行二次方程式计算的实例讲解
Dec 06 Python
python中time包实例详解
Feb 02 Python
Python绘制K线图之可视化神器pyecharts的使用
Mar 02 Python
Python实现简单的猜单词
Jun 15 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
php截取utf-8中文字符串乱码的解决方法
2010/03/29 PHP
yii添删改查实例
2015/11/16 PHP
PHP cURL获取微信公众号access_token的实例
2018/04/28 PHP
php 读取文件夹下所有图片、文件的实例
2018/10/17 PHP
基于jQuery的获取标签名的代码
2012/07/16 Javascript
javascript创建createXmlHttpRequest对象示例代码
2014/02/10 Javascript
JSON+HTML实现国家省市联动选择效果
2014/05/18 Javascript
JavaScript定义类和对象的方法
2014/11/26 Javascript
JavaScript实现添加及删除事件的方法小结
2015/08/04 Javascript
jQuery对html元素的取值与赋值实例详解
2015/12/18 Javascript
Node.js实现兼容IE789的文件上传进度条
2016/09/02 Javascript
在 Angular 中使用Chart.js 和 ng2-charts的示例代码
2017/08/17 Javascript
详解Angular中实现自定义组件的双向绑定的两种方法
2018/11/23 Javascript
通过JavaScript下载文件到本地的方法(单文件)
2019/03/17 Javascript
Vue 中可以定义组件模版的几种方式
2019/08/06 Javascript
python中常用的各种数据库操作模块和连接实例
2014/05/29 Python
Python动态加载模块的3种方法
2014/11/22 Python
简单总结Python中序列与字典的相同和不同之处
2016/01/19 Python
python实现给scatter设置颜色渐变条colorbar的方法
2018/12/13 Python
python将控制台输出保存至文件的方法
2019/01/07 Python
python3 pygame实现接小球游戏
2019/05/14 Python
python之array赋值技巧分享
2019/11/28 Python
Python接收手机短信的代码整理
2020/08/02 Python
联想新西兰官方网站:Lenovo New Zealand
2018/10/30 全球购物
获取邓白氏信用报告:Dun & Bradstreet
2019/01/22 全球购物
美国婴儿和儿童服装购物网站:PatPat
2020/10/01 全球购物
Ruby如何定义一个类
2012/10/08 面试题
开业庆典邀请函
2014/01/08 职场文书
《秋姑娘的信》教学反思
2014/02/28 职场文书
文明好少年事迹材料
2014/08/19 职场文书
离婚协议书怎么写
2014/09/12 职场文书
师德标兵事迹材料
2014/12/19 职场文书
2015驻村干部工作总结
2015/04/07 职场文书
2016中秋晚会开幕词
2016/03/03 职场文书
优秀员工演讲稿
2019/06/21 职场文书
三年级作文之趣事作文
2019/11/04 职场文书