基于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程序员开发中常犯的10个错误
Jul 07 Python
PyMongo安装使用笔记
Apr 27 Python
python3序列化与反序列化用法实例
May 26 Python
Python使用回溯法子集树模板解决爬楼梯问题示例
Sep 08 Python
Python解决N阶台阶走法问题的方法分析
Dec 28 Python
python使用Plotly绘图工具绘制柱状图
Apr 01 Python
python脚本之一键移动自定格式文件方法实例
Sep 02 Python
Python实现大数据收集至excel的思路详解
Jan 03 Python
Python2和Python3中@abstractmethod使用方法
Feb 04 Python
python 使用while循环输出*组成的菱形实例
Apr 12 Python
pyMySQL SQL语句传参问题,单个参数或多个参数说明
Jun 06 Python
利用python进行数据加载
Jun 20 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
YII中assets的使用示例
2014/07/31 PHP
php制作简单模版引擎
2016/04/07 PHP
PHP创建/删除/复制文件夹、文件
2016/05/03 PHP
Yii2中简单的场景使用介绍
2017/06/02 PHP
PHP实现表单提交数据的验证处理功能【防SQL注入和XSS攻击等】
2017/07/21 PHP
Laravel中Facade的加载过程与原理详解
2017/09/22 PHP
jQuery 入门级学习笔记及源码
2010/01/22 Javascript
jQuery控制图片的hover效果(smartRollover.js)
2012/03/18 Javascript
js特效,页面下雪的小例子
2013/06/17 Javascript
jQuery性能优化的38个建议
2014/03/04 Javascript
Jquery方式获取iframe页面中的 Dom元素
2014/05/07 Javascript
js获取数组的最后一个元素
2015/04/14 Javascript
ECMAScript6块级作用域及新变量声明(let)
2015/06/12 Javascript
javascript如何操作HTML下拉列表标签
2015/08/20 Javascript
如何解决hover在ie6中的兼容性问题
2016/12/15 Javascript
JSON与JS对象的区别与对比
2017/03/01 Javascript
详解使用create-react-app添加css modules、sasss和antd
2018/07/31 Javascript
vue+iview/elementUi实现城市多选
2019/03/28 Javascript
bootstrap Table实现合并相同行
2019/07/19 Javascript
vuex state中的数组变化监听实例
2019/11/06 Javascript
[09:59]DOTA2-DPC中国联赛2月7日Recap集锦
2021/03/11 DOTA
Python使用scrapy抓取网站sitemap信息的方法
2015/04/08 Python
对python cv2批量灰度图片并保存的实例讲解
2018/11/09 Python
详解分布式任务队列Celery使用说明
2018/11/29 Python
Django框架模板语言实例小结【变量,标签,过滤器,继承,html转义】
2019/05/23 Python
python实现最速下降法
2020/03/24 Python
Win10环境中如何实现python2和python3并存
2020/07/20 Python
Python unittest装饰器实现原理及代码
2020/09/08 Python
pytorch下的unsqueeze和squeeze的用法说明
2021/02/06 Python
酒吧总经理岗位职责
2013/12/10 职场文书
高三学生评语大全
2014/04/25 职场文书
工程承诺书怎么写
2014/05/24 职场文书
庆六一活动总结
2014/08/29 职场文书
2015年乡镇纪检工作总结
2015/04/22 职场文书
离婚答辩状怎么写
2015/05/22 职场文书
html+css实现环绕倒影加载特效
2021/07/07 HTML / CSS