基于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开发微信公众平台的方法详解【基于weixin-knife】
Jul 08 Python
python文件特定行插入和替换实例详解
Jul 12 Python
python正则表达式去除两个特殊字符间的内容方法
Dec 24 Python
Python制作微信好友背景墙教程(附完整代码)
Jul 17 Python
python之拟合的实现
Jul 19 Python
django foreignkey外键使用的例子 相当于left join
Aug 06 Python
Python实现将蓝底照片转化为白底照片功能完整实例
Dec 13 Python
Python2与Python3的区别详解
Feb 09 Python
python 实现两个线程交替执行
May 02 Python
python中urllib.request和requests的使用及区别详解
May 05 Python
哈工大自然语言处理工具箱之ltp在windows10下的安装使用教程
May 07 Python
pygame用blit()实现动画效果的示例代码
May 28 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中使用xmlreader读取xml数据示例
2014/12/29 PHP
php及codeigniter使用session-cookie的方法(详解)
2017/04/06 PHP
PHP与SQL语句写一句话木马总结
2019/10/11 PHP
javascript function、指针及内置对象
2009/02/19 Javascript
jQuery Selector选择器小结
2010/05/06 Javascript
javascript自定义startWith()和endWith()的两种方法
2013/11/11 Javascript
jQuery中ready事件用法实例
2015/01/19 Javascript
jQuery实现在textarea指定位置插入字符或表情的方法
2015/03/11 Javascript
简介AngularJS的视图功能应用
2015/06/17 Javascript
javaScript事件机制兼容【详细整理】
2016/07/23 Javascript
BootStrap轻松实现微信页面开发代码分享
2016/10/21 Javascript
js 实现获取name 相同的页面元素并循环遍历的方法
2017/02/14 Javascript
JavaScript数组和对象的复制
2017/03/21 Javascript
jQuery实现多张图片上传预览(不经过后端处理)
2017/04/29 jQuery
详解Angular2组件之间如何通信
2017/06/22 Javascript
纯javascript前端实现base64图片下载(兼容IE10+)
2018/09/14 Javascript
关于Vue项目跨平台运行问题的解决方法
2018/09/18 Javascript
python进阶教程之动态类型详解
2014/08/30 Python
python写的一个squid访问日志分析的小程序
2014/09/17 Python
python中安装Scrapy模块依赖包汇总
2017/07/02 Python
用python实现的线程池实例代码
2018/01/06 Python
对python中矩阵相加函数sum()的使用详解
2019/01/28 Python
Python selenium根据class定位页面元素的方法
2019/02/26 Python
Python3获取拉勾网招聘信息的方法实例
2019/04/03 Python
不到20行代码用Python做一个智能聊天机器人
2019/04/19 Python
python安装本地whl的实例步骤
2019/10/12 Python
Tensorflow矩阵运算实例(矩阵相乘,点乘,行/列累加)
2020/02/05 Python
DC Shoes俄罗斯官网:美国滑板鞋和服饰品牌
2020/08/19 全球购物
市场营销方案范文
2014/03/11 职场文书
廉洁使者实施方案
2014/03/29 职场文书
小学老师寄语大全
2014/04/04 职场文书
课外活动总结范文
2014/07/09 职场文书
焦裕禄观后感
2015/06/03 职场文书
女性健康知识讲座主持词
2015/07/04 职场文书
送给教师们,到底该如何写好教学反思?
2019/07/02 职场文书
教您:房贷工资收入证明应该怎么写?
2019/08/19 职场文书