调整zx_ocr的存表
This commit is contained in:
@@ -4,6 +4,7 @@ import math
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
import time
|
||||
from io import BytesIO
|
||||
|
||||
import paddle
|
||||
@@ -99,7 +100,7 @@ def information_extraction(ie, phrecs):
|
||||
with tempfile.NamedTemporaryFile(delete=False, suffix=".jpg") as temp_file:
|
||||
img["img"].save(temp_file.name)
|
||||
docs.append({"doc": temp_file.name})
|
||||
doc_phrecs.append(phrec)
|
||||
doc_phrecs.append({"phrec": phrec, "x_offset": img["x_offset"], "y_offset": img["y_offset"]})
|
||||
if not docs:
|
||||
return result
|
||||
|
||||
@@ -117,15 +118,18 @@ def information_extraction(ie, phrecs):
|
||||
logging.info(f"删除临时文件 {temp_file['doc']} 时出错: {e}")
|
||||
|
||||
now = get_default_datetime()
|
||||
id = int(time.time())
|
||||
for i in range(len(ie_results)):
|
||||
ie_result = ie_results[i]
|
||||
phrec = doc_phrecs[i]
|
||||
doc_phrec = doc_phrecs[i]
|
||||
phrec = doc_phrec["phrec"]
|
||||
result_json = json.dumps(ie_result, ensure_ascii=False)
|
||||
if len(result_json) > 5000:
|
||||
result_json = result_json[:5000]
|
||||
session = MysqlSession()
|
||||
zx_ocr = ZxOcr(pk_phhd=phrec.pk_phhd, pk_phrec=phrec.pk_phrec, cfjaddress=phrec.cfjaddress,
|
||||
content=result_json, create_time=now, update_time=now)
|
||||
zx_ocr = ZxOcr(pk_phhd=phrec.pk_phhd, pk_phrec=phrec.pk_phrec, id=id, cfjaddress=phrec.cfjaddress,
|
||||
content=result_json, x_offset=doc_phrec["x_offset"], y_offset=doc_phrec["y_offset"],
|
||||
create_time=now, update_time=now)
|
||||
session.add(zx_ocr)
|
||||
session.commit()
|
||||
session.close()
|
||||
|
||||
Reference in New Issue
Block a user