基于Python的身份证验证识别和数据处理详解
作者:郎志刚 发布时间:2021-04-22 04:43:09
标签:python,身份验证识别,数据处理
根据GB11643-1999公民身份证号码是特征组合码,由十七位数字本体码和一位数字校验码组成,排列顺序从左至右依次为:
六位数字地址码八位数字出生日期码三位数字顺序码一位数字校验码(数字10用罗马X表示)
校验系统:
校验码采用ISO7064:1983,MOD11-2校验码系统(图为校验规则样例)
用身份证号的前17位的每一位号码字符值分别乘上对应的加权因子值,得到的结果求和后对11进行取余,最后的结果放到表2检验码字符值..换算关系表中得出最后的一位身份证号码
代码:
# 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)
来源:https://www.cnblogs.com/langzhig/archive/2020/11/13/13969958.html


猜你喜欢
- while语句打印1-20的整数,并且每行打印五个数,为了实现每行5个数,我们使用一个if判断语句来实现,判断当打印出5个数之后,自动换行打
- 需求描述制作一个H5页面,打开之后可以录音,并将录音文件提交至后台微信录音最长时长为1min微信官方文档--音频接口代码如下 /
- 本文实例讲述了PHP模拟asp中response类的方法。分享给大家供大家参考。具体如下:习惯了asp或是asp.net开发的人, 他们会经
- 前言:本文研究的主要是Python实现pig Latin小游戏的简单代码,具体介绍如下。Pig Latin是一个语言游戏。步骤:1.让用户输
- 公司数据中心计划将海量数据做一次迁移,同时增加某时间字段(原来是datatime类型,现在增加一个date类型),单表数据量达到6亿多条记录
- 我对定格动画非常喜爱,也曾经在大学毕业时期制作过一部个人定格动画MV.恰当给CDC博客写文之机,给大家介绍下定格动画,分享下这门独特的拍摄艺
- 本文实例为大家分享了python绘制彩虹图的具体代码,供大家参考,具体内容如下from turtle import *#控制彩虹路径def
- 递归是一种较为抽象的数学逻辑,可以简单的理解为「程序调用自身的算法」。 * 对递归的解释是:递归(英语:Recursion),又译为递回,
- 本文参考文章,出于学习目的,写本文。开发项目时,为了维护一些经常需要变更的数据,比如数据库的连接信息、请求的url、测试数据等,需要将这些数
- 工欲善其事必先利其器,估计大部分的pythoner都是从python IDE开始了python之路。有很多的python IDE工具可以用,
- 聚合函数 count,max,min,avg,sum... select count (*) from T_Employee select
- common中存放的是整个项目中公共使用的封装方法从工程目录上可以看到区分datas中专门存放测试数据(yml文件)cases中专门集中存放
- 我在一篇文章所说,首页的“站点名称”最好用h1标签来定义,但从美观考虑,要用logo图片来代替h1,这时需要隐藏h1内的这段文字,但又不能对
- 同伪类的方式类似,伪元素通过对插人到文档中的虚构元素进行触发,从而达到某种效果。在CSS1里,有两个伪元素,即:first-letter和f
- 一、前言数据库的数据量达到一定程度之后,为避免带来系统性能上的瓶颈。需要进行数据的处理,采用的手段是分区、分片、分库、分表。二、分片(类似分
- 为什么要指定swagger的api参数api的参数有多种类型:query 参数,如 /users?role=adminpath 参数,如 /
- 一、背景大家好,我是J哥。也许你还记得,前不久复旦大学一博士生写了130行Python代码,批量识别核酸截图内容的故事。当时还被人民日报公众
- handle non numerical data举个例子,将性别属性男女转换成0-1,精通ML的小老弟们可以略过本文~~,这里不考虑稀疏向
- 随机数参与的应用场景大家一定不会陌生,比如密码加盐时会在原密码上关联一串随机数,蒙特卡洛算法会通过随机数采样等等。Python内置的rand
- Python2.x使用过程中,中文乱码解决最耳熟能详的方法就是在代码前加上#-*- coding:utf-8 –*-那么为什么需要这么做呢?