基于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实现简单温度转换的方法
Mar 13 Python
python通过colorama模块在控制台输出彩色文字的方法
Mar 19 Python
MySQL最常见的操作语句小结
May 07 Python
python 判断是否为正小数和正整数的实例
Jul 23 Python
Django重装mysql后启动报错:No module named ‘MySQLdb’的解决方法
Apr 22 Python
python逆序打印各位数字的方法
Jun 25 Python
python字符串分割及字符串的一些常规方法
Jul 24 Python
python滑块验证码的破解实现
Nov 10 Python
Python sklearn中的.fit与.predict的用法说明
Jun 28 Python
Python如何实现大型数组运算(使用NumPy)
Jul 24 Python
python简单实现9宫格图片实例
Sep 03 Python
python tkinter的消息框模块(messagebox,simpledialog)
Nov 07 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 验证码制作(网树注释思想)
2009/07/20 PHP
php实现建立多层级目录的方法
2014/07/19 PHP
php使用gzip压缩传输js和css文件的方法
2015/07/29 PHP
以实例全面讲解PHP中多进程编程的相关函数的使用
2015/08/18 PHP
PHP开发中解决并发问题的几种实现方法分析
2017/11/13 PHP
在JavaScript中重写jQuery对象的方法实例教程
2014/08/25 Javascript
jquery获得同源iframe内body下标签的值的方法
2014/09/25 Javascript
轻松掌握JavaScript代理模式
2016/08/26 Javascript
JavaScript实现多栏目切换效果
2016/12/12 Javascript
JS表单数据验证的正则表达式(常用)
2017/02/18 Javascript
jQuery实现动态给table赋值的方法示例
2017/07/04 jQuery
vue init webpack 建vue项目报错的解决方法
2018/09/29 Javascript
Vue 组件封装 并使用 NPM 发布的教程
2018/09/30 Javascript
vue实现标签云效果的方法详解
2019/08/28 Javascript
vue源码中的检测方法的实现
2019/09/26 Javascript
JS实现网站吸顶条
2020/01/08 Javascript
vue-openlayers实现地图坐标弹框效果
2020/09/24 Javascript
Vue 的 v-model用法实例
2020/11/23 Vue.js
Python for循环中的陷阱详解
2018/07/13 Python
Python3 Click模块的使用方法详解
2020/02/12 Python
Python单例模式的四种创建方式实例解析
2020/03/04 Python
印度最好的在线药品订购网站:PharmEasy
2018/11/30 全球购物
加拿大服装和鞋类零售商:Mark’s
2021/01/04 全球购物
Python中pass语句的作用是什么
2016/06/01 面试题
设计4个线程,其中两个线程每次对j增加1,另外两个线程对j每次减少1。写出程序。
2014/12/30 面试题
高中生学习生活的自我评价
2013/10/09 职场文书
拉丁舞学习者的自我评价
2013/10/27 职场文书
车祸赔偿收入证明
2014/01/09 职场文书
安卓程序员求职信
2014/02/28 职场文书
教师考察材料范文
2014/06/03 职场文书
广播体操口号
2014/06/18 职场文书
成绩报告单家长评语
2014/12/30 职场文书
幼儿园综治宣传月活动总结
2015/05/07 职场文书
详解Django的MVT设计模式
2021/04/29 Python
MySQL中VARCHAR与CHAR格式数据的区别
2021/05/26 MySQL
mysql使用instr达到in(字符串)的效果
2022/04/03 MySQL