删除无效方法

This commit is contained in:
2024-10-12 13:29:14 +08:00
parent 894cab4f0b
commit b9ac638b38

View File

@@ -5,7 +5,6 @@ import os
import cv2 import cv2
import numpy import numpy
import requests import requests
from paddleclas import PaddleClas
from tenacity import retry, stop_after_attempt, wait_random from tenacity import retry, stop_after_attempt, wait_random
from log import PROJECT_ROOT from log import PROJECT_ROOT
@@ -67,23 +66,23 @@ def split(img_path, ratio=1.414, overlap=0.05, x_compensation=3):
return split_result return split_result
def parse_rotation_angles(image): # def parse_rotation_angles(image):
""" # """
判断图片旋转角度,逆时针旋转该角度后为正。可能值['0', '90', '180', '270'] # 判断图片旋转角度,逆时针旋转该角度后为正。可能值['0', '90', '180', '270']
:param image: 图片NumPy数组或文件路径 # :param image: 图片NumPy数组或文件路径
:return: 最有可能的两个角度 # :return: 最有可能的两个角度
""" # """
angles = ['0', '90'] # angles = ['0', '90']
model = PaddleClas(model_name='text_image_orientation') # model = PaddleClas(model_name='text_image_orientation')
clas_result = model.predict(input_data=image) # clas_result = model.predict(input_data=image)
try: # try:
clas_result = next(clas_result)[0] # clas_result = next(clas_result)[0]
if clas_result['scores'][0] < 0.5: # if clas_result['scores'][0] < 0.5:
return angles # return angles
angles = clas_result['label_names'] # angles = clas_result['label_names']
except Exception as e: # except Exception as e:
logging.error('获取图片旋转角度失败', exc_info=e) # logging.error('获取图片旋转角度失败', exc_info=e)
return angles # return angles
def rotate(img_path, angle): def rotate(img_path, angle):