基于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程序与系统shell交互的方式
Apr 09 Python
TensorFlow实现Batch Normalization
Mar 08 Python
python中利用h5py模块读取h5文件中的主键方法
Jun 05 Python
python 对txt中每行内容进行批量替换的方法
Jul 11 Python
pyqt实现.ui文件批量转换为对应.py文件脚本
Jun 19 Python
python自定义函数实现最大值的输出方法
Jul 09 Python
解决python 读取excel时 日期变成数字并加.0的问题
Oct 08 Python
tornado+celery的简单使用详解
Dec 21 Python
使用OpenCV circle函数图像上画圆的示例代码
Dec 27 Python
Django 路由层URLconf的实现
Dec 30 Python
Tensorflow 模型转换 .pb convert to .lite实例
Feb 12 Python
快速了解Python开发环境Spyder
Jun 29 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
不用iconv库的gb2312与utf-8的互换函数
2006/10/09 PHP
php获取发送给用户的header信息的方法
2015/03/16 PHP
php保存信息到当前Session的方法
2015/03/16 PHP
PHP入门教程之图像处理技巧分析
2016/09/11 PHP
php使用redis的有序集合zset实现延迟队列应用示例
2020/02/20 PHP
限制文本字节数js代码
2007/03/06 Javascript
ASP中用Join和Array,可以加快字符连接速度的代码
2007/08/22 Javascript
学习ExtJS(一) 之基础前提
2009/10/07 Javascript
JSON语法五大要素图文介绍
2012/12/04 Javascript
div浮层,滚动条移动,位置保持不变的4种方法汇总
2013/12/11 Javascript
JavaScript中输出信息的方法(信息确认框-提示输入框-文档流输出)
2016/06/12 Javascript
微信小程序开发中的疑问解答汇总
2017/07/03 Javascript
JS+HTML5实现图片在线预览功能
2017/07/22 Javascript
electron实现qq快捷登录的方法示例
2018/10/22 Javascript
js简单遍历获取对象中的属性值的方法示例
2019/06/19 Javascript
python动态加载变量示例分享
2014/02/17 Python
Python中MySQLdb和torndb模块对MySQL的断连问题处理
2015/11/09 Python
对比Python中__getattr__和 __getattribute__获取属性的用法
2016/06/21 Python
Numpy数组转置的两种实现方法
2018/04/17 Python
opencv python 图像去噪的实现方法
2018/08/31 Python
Python多线程threading模块用法实例分析
2019/05/22 Python
python识别图像并提取文字的实现方法
2019/06/28 Python
Django中的用户身份验证示例详解
2019/08/07 Python
对Django的restful用法详解(自带的增删改查)
2019/08/28 Python
Python获取统计自己的qq群成员信息的方法
2019/11/15 Python
matplotlib subplot绘制多个子图的方法示例
2020/07/28 Python
python+requests接口自动化框架的实现
2020/08/31 Python
Python Selenium操作Cookie的实例方法
2021/02/28 Python
Otticanet意大利:最顶尖的世界名牌眼镜, 能得到打折季的价格
2019/03/10 全球购物
Pandora德国官网:购买潘多拉手链、戒指、项链和耳环
2020/02/20 全球购物
大学考试作弊检讨书
2014/01/30 职场文书
企业办公室主任岗位职责
2015/04/01 职场文书
同学聚会通知书
2015/04/20 职场文书
2016年基层党组织公开承诺书
2016/03/25 职场文书
公司致全体员工的感谢信
2019/06/24 职场文书
Python实现的扫码工具居然这么好用!
2021/06/07 Python