基于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 查找文件夹下所有文件 实现代码
Jul 01 Python
linux下安装easy_install的方法
Feb 10 Python
Python的IDEL增加清屏功能实例
Jun 19 Python
Python内建函数之raw_input()与input()代码解析
Oct 26 Python
深入分析python中整型不会溢出问题
Jun 18 Python
对python读写文件去重、RE、set的使用详解
Dec 11 Python
python中的错误如何查看
Jul 08 Python
python用Tkinter做自己的中文代码编辑器
Sep 07 Python
几款Python编译器比较与推荐(小结)
Oct 15 Python
python中把元组转换为namedtuple方法
Dec 09 Python
python自动化测试通过日志3分钟定位bug
Nov 20 Python
基于Pygame实现简单的贪吃蛇游戏
Dec 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使用正则过滤js脚本代码实例
2014/05/10 PHP
PHP实现把MySQL数据库导出为.sql文件实例(仿PHPMyadmin导出功能)
2014/05/10 PHP
3种php生成唯一id的方法
2015/11/23 PHP
PHP实现从PostgreSQL数据库检索数据分页显示及根据条件查找数据示例
2018/06/09 PHP
ThinkPHP5.0 图片上传生成缩略图实例代码说明
2018/06/20 PHP
漂亮的widgets,支持换肤和后期开发新皮肤(2007-4-27已更新1.7alpha)
2007/04/27 Javascript
各种常用浏览器getBoundingClientRect的解析
2009/05/21 Javascript
jQuery get和post 方法传值注意事项
2009/11/03 Javascript
JSON序列化与解析原生JS方法且IE6和chrome测试通过
2013/09/05 Javascript
javascript利用apply和arguments复用方法
2013/11/25 Javascript
jQuery中prop()方法用法实例
2015/01/05 Javascript
jQuery中addClass()方法用法实例
2015/01/05 Javascript
简单实现jQuery进度条轮播实例代码
2016/06/20 Javascript
Angular.js 4.x中表单Template-Driven Forms详解
2017/04/25 Javascript
Vue.js 使用v-cloak后仍显示变量的解决方法
2018/11/19 Javascript
uni-app使用微信小程序云函数的步骤示例
2020/05/22 Javascript
javascript实现一款好看的秒表计时器
2020/09/05 Javascript
vue自定义插件封装,实现简易的elementUi的Message和MessageBox的示例
2020/11/20 Vue.js
Python装饰器用法示例小结
2018/02/11 Python
Sanic框架请求与响应实例分析
2018/07/16 Python
CentOS 7下安装Python3.6 及遇到的问题小结
2018/11/08 Python
详解Python并发编程之创建多线程的几种方法
2019/08/23 Python
Python多线程及其基本使用方法实例分析
2019/10/29 Python
tensorflow没有output结点,存储成pb文件的例子
2020/01/04 Python
vue常用指令代码实例总结
2020/03/16 Python
Pycharm配置autopep8实现流程解析
2020/11/28 Python
一个不错的HTML5 Canvas多层点击事件监听实例
2014/04/29 HTML / CSS
英文导游欢迎词
2014/01/11 职场文书
工作表现评语
2014/01/19 职场文书
项目经理任命书
2014/06/04 职场文书
工作违纪检讨书范文
2015/01/26 职场文书
施工员岗位职责
2015/02/10 职场文书
新郎父亲婚礼致辞
2015/07/27 职场文书
三八节祝酒词
2015/08/11 职场文书
浅谈Java父子类加载顺序
2021/08/04 Java/Android
疑《守望先锋2》A测截图泄露 或将推出新模式、新界面
2022/04/03 其他游戏