独立ucloud方法,添加ucloud配置类
This commit is contained in:
10
config/ucloud.py
Normal file
10
config/ucloud.py
Normal file
@@ -0,0 +1,10 @@
|
||||
# 公钥
|
||||
PUBLIC_KEY = "4Z7QYI7qml36QRjcCjKrls7aHl1R6H6uq"
|
||||
# 私钥
|
||||
PRIVATE_KEY = "FIdW1Kev1Ge3K7GHXzSLyGG1wTnaG6LE9BxmIVubcCaG"
|
||||
# 桶
|
||||
BUCKET = "drg100"
|
||||
# 上传后缀
|
||||
UPLOAD_SUFFIX = ".cn-sh2.ufileos.com"
|
||||
# 下载后缀
|
||||
DOWNLOAD_SUFFIX = ".cn-sh2.ufileos.com"
|
||||
@@ -1,5 +1,7 @@
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
from time import sleep
|
||||
|
||||
import paddle
|
||||
@@ -20,8 +22,10 @@ from photo_review.entity.zx_phhd import ZxPhhd
|
||||
from photo_review.entity.zx_phrec import ZxPhrec
|
||||
from photo_review.util.data_util import handle_date, handle_decimal, handle_department, handle_name, \
|
||||
handle_insurance_type, handle_original_data
|
||||
from photo_review.util.ucloud import get_private_url
|
||||
from photo_review.util.util import get_default_datetime
|
||||
from ucloud import ucloud
|
||||
|
||||
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
|
||||
|
||||
# 关键信息提取
|
||||
@@ -30,7 +34,7 @@ def information_extraction(ie, phrecs):
|
||||
docs = []
|
||||
doc_phrecs = []
|
||||
for phrec in phrecs:
|
||||
pic_path = get_private_url(phrec.cfjaddress)
|
||||
pic_path = ucloud.get_private_url(phrec.cfjaddress)
|
||||
if pic_path:
|
||||
docs.append({"doc": pic_path})
|
||||
doc_phrecs.append(phrec)
|
||||
|
||||
0
ucloud/__init__.py
Normal file
0
ucloud/__init__.py
Normal file
@@ -3,18 +3,14 @@ import logging
|
||||
|
||||
from ufile import filemanager
|
||||
|
||||
public_key = "4Z7QYI7qml36QRjcCjKrls7aHl1R6H6uq"
|
||||
private_key = "FIdW1Kev1Ge3K7GHXzSLyGG1wTnaG6LE9BxmIVubcCaG"
|
||||
bucket = "drg100"
|
||||
upload_suffix = ".cn-sh2.ufileos.com"
|
||||
download_suffix = ".cn-sh2.ufileos.com"
|
||||
from config.ucloud import PUBLIC_KEY, PRIVATE_KEY, UPLOAD_SUFFIX, DOWNLOAD_SUFFIX, BUCKET
|
||||
|
||||
|
||||
def get_private_url(key):
|
||||
get_ufile_handler = filemanager.FileManager(public_key, private_key, upload_suffix, download_suffix)
|
||||
get_ufile_handler = filemanager.FileManager(PUBLIC_KEY, PRIVATE_KEY, UPLOAD_SUFFIX, DOWNLOAD_SUFFIX)
|
||||
|
||||
# 判断文件是否存在
|
||||
_, resp = get_ufile_handler.head_file(bucket, key)
|
||||
_, resp = get_ufile_handler.head_file(BUCKET, key)
|
||||
if resp.status_code != 200:
|
||||
logging.warning("uCloud中未找到(%s)! status: %d error: %s", key, resp.status_code, resp.error)
|
||||
return None
|
||||
@@ -23,5 +19,5 @@ def get_private_url(key):
|
||||
# url = get_ufile_handler.public_download_url(bucket, key)
|
||||
|
||||
# 获取私有空间下载url, expires为下载链接有效期,单位为秒
|
||||
url = get_ufile_handler.private_download_url(bucket, key, expires=3600)
|
||||
url = get_ufile_handler.private_download_url(BUCKET, key, expires=3600)
|
||||
return url
|
||||
@@ -8,8 +8,9 @@ from pprint import pprint
|
||||
from paddlenlp import Taskflow
|
||||
from paddlenlp.utils.doc_parser import DocParser
|
||||
|
||||
from ucloud import ucloud
|
||||
|
||||
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
from photo_review.util.ucloud import get_private_url
|
||||
|
||||
|
||||
def write_visual_result(image, layout=None, result=None):
|
||||
@@ -66,23 +67,23 @@ def main(model_type, pic_name=None):
|
||||
|
||||
if model_type == "ocr":
|
||||
task_path = None
|
||||
test_img_path = get_private_url(pic_name) if pic_name else "img/PH20240428000832_1_093844_2.jpg"
|
||||
test_img_path = ucloud.get_private_url(pic_name) if pic_name else "img/PH20240428000832_1_093844_2.jpg"
|
||||
schema = None
|
||||
elif model_type == "settlement":
|
||||
task_path = "../config/model/settlement_list_model"
|
||||
test_img_path = get_private_url(pic_name) if pic_name else "img/PH20240511000638_1_094306_1.jpg"
|
||||
test_img_path = ucloud.get_private_url(pic_name) if pic_name else "img/PH20240511000638_1_094306_1.jpg"
|
||||
schema = ["患者姓名", "入院日期", "出院日期", "费用总额", "个人现金支付", "个人账户支付", "自费金额", "医保类型"]
|
||||
elif model_type == "discharge":
|
||||
task_path = "../config/model/discharge_record_model"
|
||||
test_img_path = get_private_url(pic_name) if pic_name else "img/PH20240401000003_3_001938_2.jpg"
|
||||
test_img_path = ucloud.get_private_url(pic_name) if pic_name else "img/PH20240401000003_3_001938_2.jpg"
|
||||
schema = ["医院", "科别", "姓名", "入院日期", "出院日期", "主治医生"]
|
||||
elif model_type == "cost":
|
||||
task_path = "../config/model/cost_list_model"
|
||||
test_img_path = get_private_url(pic_name) if pic_name else "img/PH20240511000648_4_094542_2.jpg"
|
||||
test_img_path = ucloud.get_private_url(pic_name) if pic_name else "img/PH20240511000648_4_094542_2.jpg"
|
||||
schema = ["姓名", "入院日期", "出院日期", "费用总额"]
|
||||
elif model_type == "cost_detail":
|
||||
task_path = "../config/model/cost_list_detail_model"
|
||||
test_img_path = get_private_url(pic_name) if pic_name else "img/PH20240511000648_4_094542_2.jpg"
|
||||
test_img_path = ucloud.get_private_url(pic_name) if pic_name else "img/PH20240511000648_4_094542_2.jpg"
|
||||
schema = {"名称": ["类别", "规格", "单价", "数量", "金额"]}
|
||||
else:
|
||||
print("请输入正确的类型!")
|
||||
|
||||
Reference in New Issue
Block a user