测试清晰度模型运行情况
This commit is contained in:
7
test.py
Normal file
7
test.py
Normal file
@@ -0,0 +1,7 @@
|
||||
from util import image_util
|
||||
|
||||
if __name__ == '__main__':
|
||||
image = r'test_img/PH20240813000294_3_081442_1.jpg'
|
||||
clas_result = image_util.parse_clarity(image)
|
||||
clas_result = next(clas_result)[0]
|
||||
print(clas_result)
|
||||
BIN
test_img/PH20240813000294_3_081442_1.jpg
Normal file
BIN
test_img/PH20240813000294_3_081442_1.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 MiB |
@@ -251,3 +251,20 @@ def combined(img1, img2):
|
||||
combined_img[:height1, :width1] = img1
|
||||
combined_img[:height2, width1:width1 + width2] = img2
|
||||
return combined_img
|
||||
|
||||
|
||||
def parse_clarity(image):
|
||||
"""
|
||||
判断图片清晰度
|
||||
:param image: 图片NumPy数组或文件路径
|
||||
:return: 判断结果及置信度
|
||||
"""
|
||||
clarity_result = [1, 0]
|
||||
model = PaddleClas(model_name="clarity_assessment")
|
||||
clas_result = model.predict(input_data=image)
|
||||
try:
|
||||
clas_result = next(clas_result)[0]
|
||||
clarity_result = [clas_result["class_ids"][0], clas_result["scores"][0]]
|
||||
except Exception as e:
|
||||
logging.error("获取图片清晰度失败", exc_info=e)
|
||||
return clarity_result
|
||||
|
||||
Reference in New Issue
Block a user