基于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的Flask框架开发环境的一些技巧总结
Jul 12 Python
python中print的不换行即时输出的快速解决方法
Jul 20 Python
Django返回json数据用法示例
Sep 18 Python
python的numpy模块安装不成功简单解决方法总结
Dec 23 Python
python实现excel读写数据
Mar 02 Python
python os.path模块常用方法实例详解
Sep 16 Python
Python将8位的图片转为24位的图片实现方法
Oct 24 Python
Python pandas库中的isnull()详解
Dec 26 Python
Python下划线5种含义代码实例解析
Jul 10 Python
python代码能做成软件吗
Jul 24 Python
python连接mysql数据库并读取数据的实现
Sep 25 Python
python 读取yaml文件的两种方法(在unittest中使用)
Dec 01 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解析url的三个示例
2014/01/20 PHP
php环境无法上传文件的解决方法
2014/04/30 PHP
Javascript MD4
2006/12/20 Javascript
优化JavaScript脚本的性能的几个注意事项
2006/12/22 Javascript
Mootools 1.2教程 同时进行多个形变动画
2009/09/15 Javascript
idTabs基于JQuery的根据URL参数选择Tab插件
2012/04/11 Javascript
屏蔽script注入小例子
2013/11/12 Javascript
JS读取XML文件示例代码
2013/11/15 Javascript
js实现跨域的多种方法
2015/12/25 Javascript
angular2使用简单介绍
2016/03/01 Javascript
【经典源码收藏】基于jQuery的项目常见函数封装集合
2016/06/07 Javascript
Three.js学习之文字形状及自定义形状
2016/08/01 Javascript
浅谈JS读取DOM对象(标签)的自定义属性
2016/11/21 Javascript
基于Vue如何封装分页组件
2016/12/16 Javascript
JS查找数组中重复元素的方法详解
2017/06/14 Javascript
利用10行js代码实现上下滚动公告效果
2017/12/08 Javascript
浅谈webpack对样式的处理
2018/01/05 Javascript
使用element-ui的el-menu导航选中后刷新页面保持当前选中状态
2019/07/19 Javascript
微信小程序开发(一):服务器获取数据列表渲染操作示例
2020/06/01 Javascript
[03:44]2015国际邀请赛选手档案—Cloud9.NoTail
2015/07/28 DOTA
[58:35]OG vs EG 2019国际邀请赛淘汰赛 胜者组 BO3 第二场 8.22
2019/09/05 DOTA
不可错过的十本Python好书
2017/07/06 Python
Python操作Redis之设置key的过期时间实例代码
2018/01/25 Python
tensorflow学习笔记之简单的神经网络训练和测试
2018/04/15 Python
python实现NB-IoT模块远程控制
2018/06/20 Python
Python自动生成代码 使用tkinter图形化操作并生成代码框架
2019/09/18 Python
基于pandas中expand的作用详解
2019/12/17 Python
python爬虫看看虎牙女主播中谁最“顶”步骤详解
2020/12/01 Python
体育系毕业生求职自荐信
2014/04/16 职场文书
机电一体化毕业生自荐信
2014/06/19 职场文书
小学国旗下的演讲稿
2014/08/28 职场文书
民事和解协议书格式
2014/11/29 职场文书
2015年元旦主持词开场白
2014/12/14 职场文书
捐助感谢信
2015/01/22 职场文书
浅谈MySQL next-key lock 加锁范围
2021/06/07 MySQL
python可视化分析绘制带趋势线的散点图和边缘直方图
2022/06/25 Python