A package for ID card recognition using Moonshot AI
Project description
id_card_recognition
简介
id_card_recognition
是一个使用 Moonshot 提供的 AI 模型进行身份证识别的 Python 库。
配置
创建 .env 文件
在项目根目录下创建一个 .env
文件,并添加以下内容:
API_KEY= 你的 moonshot AI 秘钥,申请网址:https://platform.moonshot.cn/
IMAGE_DIRECTORY= 需要识别的身份证照片存放路径,默认为 ./images,图片名称可以是'.png', '.jpg', '.jpeg', '.bmp', '.gif'
RESULT_FILE_NAME= 识别结果文件名称,为文本文件,默认为 result.txt
CHOSEN_MODEL_NAME= 选择的模型名称,默认为 "moonshot-v1-8k"
示例 .env 文件
API_KEY=sk-XXXXXXXXXXX
IMAGE_DIRECTORY=./images
RESULT_FILE_NAME=result.txt
CHOSEN_MODEL_NAME=moonshot-v1-8k
使用
添加引用
在您的 Python 脚本中添加对 do_recognition
函数的引用:
from id_card_recognition.recognition import do_recognition
调用识别方法
调用 do_recognition()
方法返回识别结果。识别结果将保存在 RESULT_FILE_NAME
指定的文件中。
示例
创建一个新的 Python 文件(例如 run_id_card_recognition.py
),并编写如下代码:
from id_card_recognition.recognition import do_recognition
if __name__ == "__main__":
# 运行身份证识别
results = do_recognition()
# 打印结果
print(results)
运行示例
python run_id_card_recognition.py
许可证
MIT License
此 `README.md` 文件包含了如何配置环境变量、使用库和运行示例的详细步骤。确保您根据实际情况替换你的 API 密钥。
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file id_card_recognition-0.3.9.tar.gz
.
File metadata
- Download URL: id_card_recognition-0.3.9.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3965239e244e7a44022675016d17cc2ee525272616076069b4622c0d11b638c5 |
|
MD5 | edb59f8c10b80c5395441444cf82605f |
|
BLAKE2b-256 | f5d09321d4ccddaef9cb5cdf2aa3999dedc554dc046b093558d21e7afb0eac0b |
File details
Details for the file id_card_recognition-0.3.9-py3-none-any.whl
.
File metadata
- Download URL: id_card_recognition-0.3.9-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b18f059d7bd51ff02bec2143ea559c576dbadf0952d0e31d969408bf8cc41de |
|
MD5 | e35e0396679c788f39b44c58f655e15f |
|
BLAKE2b-256 | 4e26f9bc9a0edbcf5b1e160a940e378bc86eb5753c680f7b2aea9e92267c723e |