优化接口图片传输方式
This commit is contained in:
20
util/model_util.py
Normal file
20
util/model_util.py
Normal file
@@ -0,0 +1,20 @@
|
||||
import logging
|
||||
|
||||
import cv2
|
||||
import requests
|
||||
from tenacity import retry, stop_after_attempt, wait_random
|
||||
|
||||
|
||||
@retry(stop=stop_after_attempt(3), wait=wait_random(1, 3), reraise=True,
|
||||
after=lambda x: logging.warning('获取文档区域失败!'))
|
||||
def request_book_areas(img_path):
|
||||
url = 'http://det_api:5000/det/books'
|
||||
response = requests.post(url, {'img_path': img_path})
|
||||
if response.status_code == 200:
|
||||
response_data = response.json()
|
||||
books = []
|
||||
for books_path in response_data:
|
||||
books.append(cv2.imread(books_path))
|
||||
return books
|
||||
else:
|
||||
return []
|
||||
Reference in New Issue
Block a user