调整容器挂载文件
This commit is contained in:
@@ -238,8 +238,11 @@ cython_debug/
|
||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||
#.idea/
|
||||
|
||||
# 模型通过卷绑定挂载到容器中
|
||||
/model
|
||||
# 通过卷绑定挂载到容器中
|
||||
/log
|
||||
/services/paddle_services/log
|
||||
/services/paddle_services/model
|
||||
/tmp_img
|
||||
# docker
|
||||
Dockerfile
|
||||
docker-compose*.yml
|
||||
5
.gitignore
vendored
5
.gitignore
vendored
@@ -142,7 +142,10 @@ cython_debug/
|
||||
.idea
|
||||
|
||||
### Model
|
||||
model
|
||||
services/paddle_services/model
|
||||
|
||||
### Log Backups
|
||||
*.log.*-*-*
|
||||
|
||||
### Tmp Files
|
||||
/tmp_img
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
1. 从Git远程仓库克隆项目到本地。
|
||||
|
||||
2. 将深度学习模型复制到./model目录下,具体请看[模型更新](#模型更新)部分。
|
||||
2. 将深度学习模型复制到./services/paddle_services/model目录下,具体请看[模型更新](#模型更新)部分。
|
||||
|
||||
3. 安装docker和docker-compose。
|
||||
|
||||
|
||||
@@ -8,14 +8,16 @@ x-project:
|
||||
image: fcb_photo_review:2.0.0
|
||||
volumes:
|
||||
- ./log:/app/log
|
||||
- ./tmp_img:/app/tmp_img
|
||||
|
||||
x-paddle:
|
||||
&paddle_template
|
||||
<<: *base_template
|
||||
image: fcb_paddle:0.0.1
|
||||
volumes:
|
||||
- ./log:/app/log
|
||||
- ./model:/app/model
|
||||
- ./services/paddle_services/log:/app/log
|
||||
- ./services/paddle_services/model:/app/model
|
||||
- ./tmp_img:/app/tmp_img
|
||||
|
||||
services:
|
||||
ocr_api:
|
||||
|
||||
@@ -9,7 +9,7 @@ from . import PATIENT_NAME, ADMISSION_DATE, DISCHARGE_DATE, MEDICAL_EXPENSES
|
||||
app = Flask(__name__)
|
||||
COST_LIST_SCHEMA = PATIENT_NAME + ADMISSION_DATE + DISCHARGE_DATE + MEDICAL_EXPENSES
|
||||
COST = Taskflow('information_extraction', schema=COST_LIST_SCHEMA, model='uie-x-base',
|
||||
task_path='../../model/cost_list_model', layout_analysis=False, precision='fp16')
|
||||
task_path='model/cost_list_model', layout_analysis=False, precision='fp16')
|
||||
|
||||
|
||||
@app.route('/nlp/cost', methods=['POST'])
|
||||
|
||||
@@ -11,7 +11,7 @@ DISCHARGE_RECORD_SCHEMA = (
|
||||
HOSPITAL + DEPARTMENT + PATIENT_NAME + ADMISSION_DATE + DISCHARGE_DATE + DOCTOR + ADMISSION_ID + AGE
|
||||
)
|
||||
DISCHARGE = Taskflow('information_extraction', schema=DISCHARGE_RECORD_SCHEMA, model='uie-x-base',
|
||||
task_path='../../model/discharge_record_model', layout_analysis=False, precision='fp16')
|
||||
task_path='model/discharge_record_model', layout_analysis=False, precision='fp16')
|
||||
|
||||
|
||||
@app.route('/nlp/discharge', methods=['POST'])
|
||||
|
||||
70
services/paddle_services/log/__init__.py
Normal file
70
services/paddle_services/log/__init__.py
Normal file
@@ -0,0 +1,70 @@
|
||||
import os
|
||||
import socket
|
||||
|
||||
# 获取主机名,方便区分容器
|
||||
HOSTNAME = socket.gethostname()
|
||||
# 检测日志文件的路径是否存在,不存在则创建
|
||||
LOG_PATHS = [
|
||||
f"log/{HOSTNAME}/error",
|
||||
]
|
||||
for path in LOG_PATHS:
|
||||
if not os.path.exists(path):
|
||||
os.makedirs(path)
|
||||
|
||||
# 配置字典
|
||||
LOGGING_CONFIG = {
|
||||
'version': 1, # 必需,指定配置格式的版本
|
||||
'disable_existing_loggers': False, # 是否禁用已经存在的logger实例
|
||||
|
||||
# formatters定义了不同格式的日志样式
|
||||
'formatters': {
|
||||
'standard': {
|
||||
'format': '%(asctime)s [%(levelname)s] %(name)s: %(message)s',
|
||||
'datefmt': '%Y-%m-%d %H:%M:%S',
|
||||
},
|
||||
},
|
||||
|
||||
# handlers定义了不同类型的日志处理器
|
||||
'handlers': {
|
||||
'console': {
|
||||
'class': 'logging.StreamHandler', # 控制台处理器
|
||||
'level': 'DEBUG',
|
||||
'formatter': 'standard',
|
||||
'stream': 'ext://sys.stdout', # 输出到标准输出,默认编码跟随系统,一般为UTF-8
|
||||
},
|
||||
'file': {
|
||||
'class': 'logging.handlers.TimedRotatingFileHandler', # 文件处理器,支持日志滚动
|
||||
'level': 'INFO',
|
||||
'formatter': 'standard',
|
||||
'filename': f'log/{HOSTNAME}/fcb_photo_review.log', # 日志文件路径
|
||||
'when': 'midnight',
|
||||
'interval': 1,
|
||||
'backupCount': 14, # 保留的备份文件数量
|
||||
'encoding': 'utf-8', # 显式指定文件编码为UTF-8以支持中文
|
||||
},
|
||||
'error': {
|
||||
'class': 'logging.handlers.TimedRotatingFileHandler',
|
||||
'level': 'INFO',
|
||||
'formatter': 'standard',
|
||||
'filename': f'log/{HOSTNAME}/error/fcb_photo_review_error.log',
|
||||
'when': 'midnight',
|
||||
'interval': 1,
|
||||
'backupCount': 14,
|
||||
'encoding': 'utf-8',
|
||||
},
|
||||
},
|
||||
|
||||
# loggers定义了日志记录器
|
||||
'loggers': {
|
||||
'': { # 根记录器
|
||||
'handlers': ['console', 'file'], # 关联的处理器
|
||||
'level': 'DEBUG', # 根记录器的级别
|
||||
'propagate': False, # 是否向上级传播日志信息
|
||||
},
|
||||
'error': {
|
||||
'handlers': ['console', 'file', 'error'],
|
||||
'level': 'DEBUG',
|
||||
'propagate': False,
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -15,7 +15,7 @@ SETTLEMENT_LIST_SCHEMA = (
|
||||
+ UPPERCASE_MEDICAL_EXPENSES
|
||||
)
|
||||
SETTLEMENT_IE = Taskflow('information_extraction', schema=SETTLEMENT_LIST_SCHEMA, model='uie-x-base',
|
||||
task_path='../../model/settlement_list_model', layout_analysis=False, precision='fp16')
|
||||
task_path='model/settlement_list_model', layout_analysis=False, precision='fp16')
|
||||
|
||||
|
||||
@app.route('/nlp/settlement', methods=['POST'])
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import logging
|
||||
import os
|
||||
|
||||
from flask import jsonify
|
||||
@@ -13,6 +14,7 @@ def process_request(func):
|
||||
result = func(*args, **kwargs)
|
||||
return jsonify(result), 200
|
||||
except Exception as e:
|
||||
logging.getLogger("error").error(e, exc_info=e)
|
||||
return jsonify({'error': str(e)}), 500
|
||||
|
||||
return wrapper
|
||||
|
||||
@@ -125,20 +125,20 @@ def main(model_type, pic_name=None):
|
||||
"drg103") if pic_name else "../test_img/PH20240725004467_3_185708_1.jpg"
|
||||
schema = None
|
||||
elif model_type == "settlement":
|
||||
task_path = "../model/settlement_list_model"
|
||||
task_path = "../services/paddle_services/model/settlement_list_model"
|
||||
test_img_path = ufile.get_private_url(pic_name) if pic_name else "img/PH20240511000638_1_094306_1.jpg"
|
||||
schema = ["患者姓名", "入院日期", "出院日期", "费用总额", "个人现金支付", "个人账户支付", "自费金额",
|
||||
"医保类型", "住院号", "医保结算单号码", "大写总额"]
|
||||
elif model_type == "discharge":
|
||||
task_path = "../model/discharge_record_model"
|
||||
task_path = "../services/paddle_services/model/discharge_record_model"
|
||||
test_img_path = ufile.get_private_url(pic_name) if pic_name else "img/PH20240401000003_3_001938_2.jpg"
|
||||
schema = ["医院", "科室", "患者姓名", "入院日期", "出院日期", "主治医生", "住院号", "年龄"]
|
||||
elif model_type == "cost":
|
||||
task_path = "../model/cost_list_model"
|
||||
task_path = "../services/paddle_services/model/cost_list_model"
|
||||
test_img_path = ufile.get_private_url(pic_name) if pic_name else "img/PH20240511000648_4_094542_2.jpg"
|
||||
schema = ["患者姓名", "入院日期", "出院日期", "费用总额"]
|
||||
elif model_type == "cost_detail":
|
||||
task_path = "../model/cost_list_detail_model"
|
||||
task_path = "../services/paddle_services/model/cost_list_detail_model"
|
||||
test_img_path = ufile.get_private_url(pic_name) if pic_name else "img/PH20240511000648_4_094542_2.jpg"
|
||||
schema = {"名称": ["类别", "规格", "单价", "数量", "金额"]}
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user