基于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删除列表中重复记录的方法
Apr 28 Python
django实现分页的方法
May 26 Python
Python中死锁的形成示例及死锁情况的防止
Jun 14 Python
Python学习入门之区块链详解
Jul 25 Python
Python实现简单的用户交互方法详解
Sep 25 Python
详解Matplotlib绘图之属性设置
Aug 23 Python
python自动保存百度盘资源到百度盘中的实例代码
Aug 26 Python
使用PyCharm进行远程开发和调试的实现
Nov 04 Python
python 画函数曲线示例
Dec 04 Python
tensorflow指定CPU与GPU运算的方法实现
Apr 21 Python
Python调用飞书发送消息的示例
Nov 10 Python
OpenCV-Python使用cv2实现傅里叶变换
Jun 09 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
国产动画《伍六七》原声大碟大卖,啊哈娱乐引领音乐赋能IP的新尝试
2020/03/08 国漫
php的array_multisort()使用方法介绍
2012/05/16 PHP
关于PHP实现异步操作的研究
2013/02/03 PHP
php数组声明、遍历、数组全局变量使用小结
2013/06/05 PHP
有关于PHP中常见数据类型的汇总分享
2014/01/06 PHP
动态调用css文件——jquery的应用
2007/02/20 Javascript
JavaScript 替换Html标签实现代码
2009/10/14 Javascript
网络图片延迟加载实现代码 超越jquery控件
2010/03/27 Javascript
JQuery中判断一个元素下面是否有内容或者有某个标签的判断代码
2012/02/02 Javascript
jquery三个关闭弹出层的小示例
2013/11/05 Javascript
JavaScript中的操作符==与===介绍
2014/12/31 Javascript
Bootstrap开发实战之第一次接触Bootstrap
2016/06/02 Javascript
JS中的hasOwnProperty()和isPrototypeOf()属性实例详解
2016/08/11 Javascript
Vue数据驱动模拟实现4
2017/01/12 Javascript
关于javascript sort()排序你可能忽略的一点理解
2017/07/18 Javascript
使用JS模拟锚点跳转的实例
2018/02/01 Javascript
vue中过滤器filter的讲解
2019/01/21 Javascript
javascript前端和后台进行数据交互方法示例
2020/08/07 Javascript
js实现带有动画的返回顶部
2020/08/09 Javascript
仅用50行代码实现一个Python编写的计算器的教程
2015/04/17 Python
Python模块结构与布局操作方法实例分析
2017/07/24 Python
python2 与python3的print区别小结
2018/01/16 Python
python opencv 图像尺寸变换方法
2018/04/02 Python
windows下python和pip安装教程
2018/05/25 Python
python和shell监控linux服务器的详细代码
2018/06/22 Python
Python实现字典排序、按照list中字典的某个key排序的方法示例
2018/12/18 Python
对python中url参数编码与解码的实例详解
2019/07/25 Python
pycharm 2018 激活码及破解补丁激活方式
2020/09/21 Python
使用Keras实现Tensor的相乘和相加代码
2020/06/18 Python
信息专业本科生个人的自我评价
2013/10/28 职场文书
俄语翻译实习生的自我评价分享
2013/11/06 职场文书
感恩节红领巾广播稿
2014/02/11 职场文书
毕业证明书
2015/06/19 职场文书
中学教师读书笔记
2015/07/01 职场文书
python实现批量提取指定文件夹下同类型文件
2021/04/05 Python
CocosCreator如何实现划过的位置显示纹理
2021/04/14 Javascript