基于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中的__new__与__init__魔术方法理解笔记
Nov 08 Python
python实现定时播放mp3
Mar 29 Python
Python Matplotlib库入门指南
May 18 Python
Python for Informatics 第11章 正则表达式(一)
Apr 21 Python
Fabric 应用案例
Aug 28 Python
用TensorFlow实现多类支持向量机的示例代码
Apr 28 Python
python 将数据保存为excel的xls格式(实例讲解)
May 03 Python
Sanic框架基于类的视图用法示例
Jul 18 Python
Python异常处理例题整理
Jul 07 Python
python3实现从kafka获取数据,并解析为json格式,写入到mysql中
Dec 23 Python
Python如何使用内置库matplotlib绘制折线图
Feb 24 Python
Pytorch中Softmax与LogSigmoid的对比分析
Jun 05 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 移除数组重复元素的一点说明
2008/11/27 PHP
PHP+ajax 无刷新删除数据
2010/02/20 PHP
php防止SQL注入详解及防范
2013/11/12 PHP
php 伪静态之IIS篇
2014/06/02 PHP
实例讲解PHP面向对象之多态
2014/08/20 PHP
Zend Framework+smarty用法实例详解
2016/03/19 PHP
PHP中SERIALIZE和JSON的序列化与反序列化操作区别分析
2016/10/11 PHP
php strftime函数获取日期时间(switch用法)
2018/05/16 PHP
JQuery,Extjs,YUI,Prototype,Dojo 等JS框架的区别和应用场景简述
2010/04/15 Javascript
JS两种定义方式的区别、内部原理
2013/11/21 Javascript
推荐 21 款优秀的高性能 Node.js 开发框架
2014/08/18 Javascript
jQuery实现表单提交时判断的方法
2014/12/13 Javascript
Node.js编写组件的三种实现方式
2016/02/25 Javascript
Bootstrap Validator 表单验证
2016/07/25 Javascript
微信小程序 在Chrome浏览器上运行以及WebStorm的使用
2016/09/27 Javascript
JS 滚动事件window.onscroll与position:fixed写兼容IE6的回到顶部组件
2016/10/10 Javascript
nodejs基础应用
2017/02/03 NodeJs
Vue.js展示AJAX数据简单示例讲解
2017/03/29 Javascript
动态加载JavaScript文件的3种方式
2018/05/05 Javascript
angular6的响应式表单的实现
2018/10/10 Javascript
JQuery Ajax执行跨域请求数据的解决方案
2018/12/10 jQuery
这应该是最详细的响应式系统讲解了
2019/07/22 Javascript
python对html代码进行escape编码的方法
2015/05/04 Python
Python聚类算法之DBSACN实例分析
2015/11/20 Python
Python实现查找匹配项作处理后再替换回去的方法
2017/06/10 Python
Python把csv数据写入list和字典类型的变量脚本方法
2018/06/15 Python
详解Django中间件执行顺序
2018/07/16 Python
Python字符编码转码之GBK,UTF8互转
2020/02/09 Python
如何教少儿学习Python编程
2020/07/10 Python
anaconda安装pytorch1.7.1和torchvision0.8.2的方法(亲测可用)
2021/02/01 Python
HTML5仿手机微信聊天界面
2016/03/18 HTML / CSS
一些Unix笔试题和面试题
2013/01/22 面试题
个人求职简历的自我评价范文
2013/10/09 职场文书
《小小雨点》教学反思
2014/02/18 职场文书
2014年政风行风工作总结
2014/11/22 职场文书
2015年保送生自荐信
2015/03/24 职场文书