基于Python的身份证验证识别和数据处理详解
作者:郎志刚 时间:2021-04-22 04:43:09
根据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
标签:python,身份验证识别,数据处理
0
投稿
猜你喜欢
django 快速启动数据库客户端程序的方法示例
2023-07-31 09:31:59
Python使用PyQt5/PySide2编写一个极简的音乐播放器功能
2023-11-23 16:32:45
最近写的一个asp缓存函数
2008-11-25 14:07:00
asp如何制作一个搜索引擎链接程序?
2010-07-07 12:26:00
Web Forms 2.0
2008-07-24 12:47:00
用Dreamweaver实现飘浮光球特效
2008-03-03 12:28:00
详谈Python基础之内置函数和递归
2021-12-19 21:55:40
从绘画语言的发展,看视觉设计风格
2008-08-03 17:11:00
全面剖析Python的Django框架中的项目部署技巧第1/2页
2021-09-24 23:46:58
TensorFlow实现Batch Normalization
2023-02-03 05:20:15
python提效小工具之统计xmind用例数量(源码)
2021-11-26 21:42:44
pytorch安装及环境配置的完整过程
2023-06-19 23:53:20
Highcharts 图表中图例显示状态存储的功能设计详解
2023-05-30 02:01:09
php中strtotime函数性能分析
2023-11-22 13:21:05
JS实现仿新浪微博发布内容为空时提示功能代码
2023-08-22 21:52:13
一文搞懂Python中is和==的区别
2023-11-15 09:42:27
Python中内置数据类型list,tuple,dict,set的区别和用法
2022-09-10 05:59:46
Python模拟键盘输入自动登录TGP
2021-11-04 11:27:22
OpenCV计算平均值cv::mean实例代码
2023-06-19 10:26:02
python 第三方库的安装及pip的使用详解
2023-12-27 07:06:53