基于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 django集成cas验证系统
Jul 14 Python
Windows上使用virtualenv搭建Python+Flask开发环境
Jun 07 Python
用python记录运行pid,并在需要时kill掉它们的实例
Jan 16 Python
Python用sndhdr模块识别音频格式详解
Jan 11 Python
使用Python搭建虚拟环境的配置方法
Feb 28 Python
TensorFlow变量管理详解
Mar 10 Python
tensorflow 使用flags定义命令行参数的方法
Apr 23 Python
python 列表降维的实例讲解
Jun 28 Python
python实现任意位置文件分割的实例
Dec 14 Python
Python通过paramiko远程下载Linux服务器上的文件实例
Dec 27 Python
你可能不知道的Python 技巧小结
Jan 29 Python
Python切片列表字符串如何实现切换
Aug 06 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实现telnet功能示例
2014/04/08 PHP
typecho插件编写教程(四):插件挂载
2015/05/28 PHP
php使用ffmpeg获取视频信息并截图的实现方法
2016/05/03 PHP
PHP+MySql+jQuery实现的"顶"和"踩"投票功能
2016/05/21 PHP
php post换行的方法
2020/02/03 PHP
Javascript 继承机制的实现
2009/08/12 Javascript
js更优雅的兼容
2010/08/12 Javascript
EXTJS FORM HIDDEN TEXTFIELD 赋值 使用value不好用的问题
2011/04/16 Javascript
关于jQuery参考实例2.0 用jQuery选择元素
2013/04/07 Javascript
使用JS取得焦点(focus)元素代码
2014/03/22 Javascript
jQuery实现仿Google首页拖动效果的方法
2015/05/04 Javascript
JavaScript实现点击按钮字体放大、缩小
2016/02/29 Javascript
微信小程序教程系列之新建页面(4)
2017/04/17 Javascript
Js经典案例的实例代码
2018/05/10 Javascript
解决vue项目nginx部署到非根目录下刷新空白的问题
2018/09/27 Javascript
webpack4之如何编写loader的方法步骤
2019/06/06 Javascript
Nodejs中使用puppeteer控制浏览器中视频播放功能
2019/08/26 NodeJs
vue组件创建的三种方式小结
2020/02/03 Javascript
python爬取亚马逊书籍信息代码分享
2017/12/09 Python
python 读取dicom文件,生成info.txt和raw文件的方法
2019/01/24 Python
利用python list完成最简单的DB连接池方法
2019/08/09 Python
Python爬虫+tkinter界面实现历史天气查询的思路详解
2021/02/22 Python
用HTML5制作视频拼图的教程
2015/05/13 HTML / CSS
video下autoplay属性无效的解决方法(添加muted属性)
2020/05/19 HTML / CSS
办公室副主任岗位职责
2013/11/25 职场文书
公司担保书范文
2014/05/21 职场文书
违反交通法规检讨书
2014/09/10 职场文书
群众路线自我剖析材料
2014/10/08 职场文书
骨干教师考核评语
2014/12/31 职场文书
文明倡议书
2015/01/19 职场文书
年会邀请函范文
2015/01/30 职场文书
装饰施工员岗位职责
2015/04/11 职场文书
好员工观后感
2015/06/17 职场文书
Python实现Telnet自动连接检测密码的示例
2021/04/16 Python
MySQL 开窗函数
2022/02/15 MySQL
Python实现科学占卜 让视频自动打码
2022/04/09 Python