基于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写asp详细讲解
Dec 16 Python
python教程之用py2exe将PY文件转成EXE文件
Jun 12 Python
详解Python中的多线程编程
Apr 09 Python
python获取网页中所有图片并筛选指定分辨率的方法
Mar 31 Python
浅析Python数据处理
May 02 Python
python判断一个数是否能被另一个整数整除的实例
Dec 12 Python
python并发编程多进程 互斥锁原理解析
Aug 20 Python
学习Django知识点分享
Sep 11 Python
python实现两个一维列表合并成一个二维列表
Dec 02 Python
Python logging模块进行封装实现原理解析
Aug 07 Python
Python实现自动签到脚本的示例代码
Aug 19 Python
Python调用JavaScript代码的方法
Oct 27 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中使用sockets:从新闻组中获取文章
2006/10/09 PHP
PHP 出现乱码和Sessions验证问题的解决方法!
2008/12/06 PHP
PHP 文件类型判断代码
2009/03/13 PHP
浅谈PHP 闭包特性在实际应用中的问题
2009/10/30 PHP
Zend Framework教程之Autoloading用法详解
2016/03/08 PHP
laravel自定义分页效果
2017/07/23 PHP
ko knockoutjs动态属性绑定技巧应用
2012/11/14 Javascript
javascript中AJAX用法实例分析
2015/01/30 Javascript
使用控制台破解百小度一个月只准改一次名字
2015/08/13 Javascript
谈谈impress.js初步理解
2015/09/09 Javascript
js实现延时加载Flash的方法
2015/11/26 Javascript
浅谈JS的基础类型与引用类型
2016/09/13 Javascript
浅谈js的解析顺序 作用域 严格模式
2017/10/23 Javascript
JavaScript程序设计高级算法之动态规划实例分析
2017/11/24 Javascript
[03:04]DOTA2英雄基础教程 影魔
2013/12/11 DOTA
[01:12:35]Spirit vs Navi Supermajor小组赛 A组败者组第一轮 BO3 第二场 6.2
2018/06/03 DOTA
python中正则表达式的使用详解
2014/10/17 Python
python实现通过pil模块对图片格式进行转换的方法
2015/03/24 Python
总结网络IO模型与select模型的Python实例讲解
2016/06/27 Python
python中nan与inf转为特定数字方法示例
2017/05/11 Python
Python走楼梯问题解决方法示例
2018/07/25 Python
python使用matplotlib绘制热图
2018/11/07 Python
Django学习笔记之为Model添加Action
2019/04/30 Python
Django中如何使用sass的方法步骤
2019/07/09 Python
flask框架单元测试原理与用法实例分析
2019/07/23 Python
python在OpenCV里实现投影变换效果
2019/08/30 Python
pytorch如何冻结某层参数的实现
2020/01/10 Python
Python使用grequests并发发送请求的示例
2020/11/05 Python
HTML5 transform三维立方体实现360无死角三维旋转效果
2014/08/22 HTML / CSS
美国珠宝店:Helzberg Diamonds
2018/10/24 全球购物
最好的意大利皮夹克:D’Arienzo
2018/12/04 全球购物
金蝶的一道SQL笔试题
2012/12/18 面试题
小学教师自我剖析材料
2014/09/29 职场文书
2014年无财产无子女离婚协议书范本
2014/10/09 职场文书
2015年领导干部廉洁自律工作总结
2015/05/26 职场文书
CentOS 7安装mysql5.7使用XtraBackUp备份工具命令详解
2022/04/12 MySQL