基于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通过exifread模块获得图片exif信息的方法
Mar 16 Python
python开启多个子进程并行运行的方法
Apr 18 Python
利用Python批量生成任意尺寸的图片
Aug 29 Python
Python中偏函数用法示例
Jun 07 Python
Python实现将多个空格换为一个空格.md的方法
Dec 20 Python
详解pandas库pd.read_excel操作读取excel文件参数整理与实例
Feb 17 Python
pandas 中对特征进行硬编码和onehot编码的实现
Dec 20 Python
python GUI库图形界面开发之PyQt5布局控件QHBoxLayout详细使用方法与实例
Mar 06 Python
pandas中ix的使用详细讲解
Mar 09 Python
Python限制内存和CPU使用量的方法(Unix系统适用)
Aug 04 Python
python实现KNN近邻算法
Dec 30 Python
Python结合百度语音识别实现实时翻译软件的实现
Jan 18 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
《OVERLORD》第四季,终于等到你!
2020/03/02 日漫
php smarty模版引擎中的缓存应用
2009/12/11 PHP
完美解决PHP中的Cannot modify header information 问题
2013/08/12 PHP
使用php+swoole对client数据实时更新(一)
2016/01/07 PHP
PHP实现对xml进行简单的增删改查(CRUD)操作示例
2017/05/19 PHP
Windows 下安装 swoole 图文教程(php)
2017/06/05 PHP
PHP针对redis常用操作实例详解
2019/08/17 PHP
laravel 解决后端无法获取到前端Post过来的值问题
2019/10/22 PHP
Javascript(AJAX)解析XML的代码(兼容FIREFOX/IE)
2010/07/11 Javascript
js确认删除对话框效果的示例代码
2014/02/20 Javascript
解析浏览器端的AJAX缓存机制
2016/06/21 Javascript
EasyUI折叠表格层次显示detailview详解及实例
2016/12/28 Javascript
bootstrap网格系统使用方法解析
2017/01/13 Javascript
JavaScript实现父子dom同时绑定两个点击事件,一个用捕获,一个用冒泡时执行顺序的方法
2017/03/30 Javascript
基于Proxy的小程序状态管理实现
2019/06/14 Javascript
实现一个 Vue 吸顶锚点组件方法
2019/07/10 Javascript
[52:32]完美世界DOTA2联赛PWL S2 Magma vs LBZS 第三场 11.18
2020/11/18 DOTA
推荐下python/ironpython:从入门到精通
2007/10/02 Python
不同版本中Python matplotlib.pyplot.draw()界面绘制异常问题的解决
2017/09/24 Python
python3.4爬虫demo
2019/01/22 Python
selenium+python自动化测试之多窗口切换
2019/01/23 Python
python tkinter控件布局项目实例
2019/11/04 Python
python之array赋值技巧分享
2019/11/28 Python
使用pandas的box_plot去除异常值
2019/12/10 Python
python脚本后台执行方式
2019/12/21 Python
解决Python数据可视化中文部分显示方块问题
2020/05/16 Python
python 常用日期处理-- datetime 模块的使用
2020/09/02 Python
我的梦中国梦演讲稿
2014/04/23 职场文书
电气工程及其自动化专业毕业生自荐信
2014/06/21 职场文书
开展党的群众路线教育实践活动工作总结
2014/11/05 职场文书
市级三好学生评语
2014/12/29 职场文书
学校社团活动总结
2015/05/07 职场文书
2015年公司中秋节致辞
2015/07/31 职场文书
优秀学生主要事迹怎么写
2015/11/04 职场文书
吃通javascript正则表达式
2021/04/21 Javascript
解决SpringBoot文件上传临时目录找不到的问题
2021/07/01 Java/Android