基于PaddleOCR的数字显示器字符识别
基于PaddleOCR的数字显示器字符识别
项目介绍
在电力工业的100多年历史中,“智能电表”仍处于部署和使用的初级阶段。 由于电表是电力公司的前端“收银机”,必须十分精确。
尽管对于电表有大量的要求,性能规范和法规,并且电力公司试图确保电表精度,但实际上,一旦电表设计经过认证、制造和安装,大多数电表的精度的确认仅停留于生产刚结束时的出厂测试阶段。 特定电表在退役前的现场性能只能通过统计样本测试来估计。
此外,窃电是电力公司收入损失的主要根源。 虽然通常认为面临这一问题的主要是发展中经济体,但在许多发达地区也日益严重。 例如,英国天然气和电力市场办公室(Ofgem)在2013年7月发布一份题为“阻止窃电–诊断”的报告,其中估计英国每年发生的窃电价值超过2亿英镑,电力公司还需另外投资2500万英镑防窃电、修理或更换被篡改的设备。
了解整个电表的精度很关键
智能电表相对于电子和机械电表的主要优势是连通性。 联网智能电表可远程报告用电量、实施断电管理、收集使用时间数据并防止某些类型的窃电。 不过,有没有可能对电表本身关键的测量功能执行更精密的诊断?
其他具有关键任务功能的行业,例如汽车和工业,对诊断要求引入了“功能安全性”概念,其本质是检查设备以确定其在使用前、使用中和使用后是否正常运行。 电力电表行业的此类功能之一是现场使用寿命期间的电表精度。
目前电表执行现场样本测试,仅依靠现场电表内部元器件仍保持在校准范围内来估计精度,但此方法存在风险。 现场精度监控很重要,因为精度受传感器影响,传感器则暴露于高电流、电压事件和恶劣的环境。 因此,诊断必须包括监控整个电表,包括传感器和所有电子元件。
电表精度检查通常需要人为干预、断开现场连接和采用专用设备,因此需投入大量成本或实施复杂的拆解才能在现场完成。
针对以上这些分析,使用PaddleOCR可以处理并解决部分场景下的电表读数问题。
# 导入依赖库
import os
from tqdm import tqdm
import cv2
import csv
from PIL import Image
import matplotlib.pyplot as plt
import warnings
warnings.filterwarnings("ignore")
!pip install paddleocr==2.4.*
数据处理
# 解压测试数据
!unzip -oq /home/aistudio/data/data169810/test.zip -d /home/aistudio/work/dataset
在进行电表读数之前,先进行数据可视化
数据可视化
# 可视化绘图
def imshow_image(img_path):
img = Image.open(img_path)
plt.figure("test_img", figsize=(5,5))
plt.imshow(img)
plt.show()
# 数据可视化
img_path= "/home/aistudio/work/dataset/test/133102_steerPoint5_preset1255_20220917221726_v.jpeg"
imshow_image(img_path)
问题分析
要处理电表中的数据,可以分为步骤,拆解为以下问题:
- 1.感兴趣区域定位问题
- 2.OCR读数问题
针对问题1,经过实验与探索,也找到两种方案:
方案1是,直接利用PaddleOCR默认自带的检测器,筛选掉其他无效的框体和信息,剩下的就是有用的。(未经过训练的,直接使用预训练模型)
方案2是,通过Opencv图像处理的方法,根据电表字符区域特征进行相应的轮廓提取和颜色筛选,从而保证其得到有效的定位。
方案3是,收集场景下的大量电表字符识别数据,制作数据集并进行标记,分别训练其定位和识别模型。
考虑到时间成本和人工成本问题,这里优先选择前两种方案。
下面是使用Opencv来进行ROI区域定位的方法。
定位OCR区域
import cv2
import numpy as np
import os
def find_biggest_contour(image):
"""获取最大轮廓"""
image = image.copy()
contours, hierarchy = cv2.findContours(image, cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)
contour_sizes = [(cv2.contourArea(contour), contour) for contour in contours]
biggest_contour = max(contour_sizes, key=lambda x: x[0])[1]
return biggest_contour
def get_find_display(input_path, lower=(0, 0, 0), higher=(255, 255, 255), output_path='./'):
"""查找ROI轮廓"""
img = cv2.imread(input_path)
# print('input:', input_path)
filename = input_path.split('/')[-1]
f_name = filename.split('.')[0]
# print('filename:', filename, 'f_name:', f_name)
global img_crop
lowHue = lower[0]
lowSat = lower[1]
lowVal = lower[2]
highHue = higher[0]
highSat = higher[1]
highVal = higher[2]
# 可选择不同的模糊方法
frameBGR = cv2.GaussianBlur(img, (7, 7), 0)
# 转换为HSV颜色空间
hsv = cv2.cvtColor(frameBGR, cv2.COLOR_BGR2HSV)
# 定义HSV值颜色范围
colorLow = np.array([lowHue, lowSat, lowVal])
colorHigh = np.array([highHue, highSat, highVal])
mask = cv2.inRange(hsv, colorLow, colorHigh)
kernal = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (7, 7))
mask = cv2.morphologyEx(mask, cv2.MORPH_CLOSE, kernal)
mask = cv2.morphologyEx(mask, cv2.MORPH_OPEN, kernal)
biggest_contour = find_biggest_contour(mask)
# cv2.drawContours(img, biggest_contour, -1, (0, 255, 0), 2)
print('cnt_len:', len(biggest_contour))
# 将遮罩放在原始图像的上方。
result_img = cv2.bitwise_and(img, img, mask=mask)
if biggest_contour is not None:
x, y, w, h = cv2.boundingRect(biggest_contour)
print(x, y, w, h)
img_crop = img[y:y + h, x:x + w]
print('wpath:', output_path+filename)
save_path = output_path + filename
if not os.path.exists(output_path):
os.mkdir(output_path)
cv2.imwrite(save_path, img_crop)
else:
img_crop = img
return result_img, img_crop
output_path = '/home/aistudio/work/roi/'
img_roi = '/home/aistudio/work/dataset/test/133102_steerPoint5_preset1255_20220917221726_v.jpeg'
lower = (0, 80, 0)
higher = (255, 255, 255)
result_img, img_crop = get_find_display(img_roi, lower, higher, output_path)
cnt_len: 573
67 33 483 208
wpath: /home/aistudio/work/roi/133102_steerPoint5_preset1255_20220917221726_v.jpeg
下图为本地运行结果,仅供参考。
在jupyter中运行查看下保存的结果
img_roi_path= "/home/aistudio/work/roi/133102_steerPoint5_preset1255_20220917221726_v.jpeg"
imshow_image(img_roi_path)
得到上图这样的结果后,可以直接将图片丢到PaddleOCR自带方法去识别。
from paddleocr import PaddleOCR
ocr = PaddleOCR()
def rec_display_roi(img_roi):
ocr = PaddleOCR()
result = ocr.ocr(img_roi, det=False)
return result[0][0], result[0][1]
rec_display_roi(img_roi_path)
方案2,直接使用PaddleOCR将所有可能是OCR的对象进行检测和识别。
再从中筛选要的结果。
初探OCR识别读数
from paddleocr import PaddleOCR, draw_ocr
# Paddleocr目前支持的多语言语种可以通过修改lang参数进行切换
# 例如`ch`, `en`, `fr`, `german`, `korean`, `japan`
ocr = PaddleOCR(use_angle_cls=True, lang="ch") # need to run only once to download and load model into memory
img_path = '/home/aistudio/work/dataset/test/133102_steerPoint5_preset1255_20220917221726_v.jpeg'
save_path = '/home/aistudio/work/dst/result.jpg'
result = ocr.ocr(img_path, cls=True)
for line in result:
print(line)
# 显示结果
from PIL import Image
image = Image.open(img_path).convert('RGB')
boxes = [line[0] for line in result]
txts = [line[1][0] for line in result]
scores = [line[1][1] for line in result]
im_show = draw_ocr(image, boxes, txts, scores, font_path='/home/aistudio/work/font/simfang.ttf')
im_show = Image.fromarray(im_show)
im_show.save(save_path)
imshow_image(save_path)
[2022/09/22 14:46:03] ppocr DEBUG: Namespace(alpha=1.0, benchmark=False, beta=1.0, cls_batch_num=6, cls_image_shape='3, 48, 192', cls_model_dir='/home/aistudio/.paddleocr/whl/cls/ch_ppocr_mobile_v2.0_cls_infer', cls_thresh=0.9, cpu_threads=10, crop_res_save_dir='./output', det=True, det_algorithm='DB', det_db_box_thresh=0.6, det_db_score_mode='fast', det_db_thresh=0.3, det_db_unclip_ratio=1.5, det_east_cover_thresh=0.1, det_east_nms_thresh=0.2, det_east_score_thresh=0.8, det_fce_box_type='poly', det_limit_side_len=960, det_limit_type='max', det_model_dir='/home/aistudio/.paddleocr/whl/det/ch/ch_PP-OCRv2_det_infer', det_pse_box_thresh=0.85, det_pse_box_type='quad', det_pse_min_area=16, det_pse_scale=1, det_pse_thresh=0, det_sast_nms_thresh=0.2, det_sast_polygon=False, det_sast_score_thresh=0.5, draw_img_save_dir='./inference_results', drop_score=0.5, e2e_algorithm='PGNet', e2e_char_dict_path='./ppocr/utils/ic15_dict.txt', e2e_limit_side_len=768, e2e_limit_type='max', e2e_model_dir=None, e2e_pgnet_mode='fast', e2e_pgnet_score_thresh=0.5, e2e_pgnet_valid_set='totaltext', enable_mkldnn=False, fourier_degree=5, gpu_mem=500, help='==SUPPRESS==', image_dir=None, ir_optim=True, label_list=['0', '180'], label_map_path='./vqa/labels/labels_ser.txt', lang='ch', layout_label_map=None, layout_path_model='lp://PubLayNet/ppyolov2_r50vd_dcn_365e_publaynet/config', max_batch_size=10, max_seq_length=512, max_text_length=25, min_subgraph_size=15, mode='structure', model_name_or_path=None, ocr_version='PP-OCRv2', output='./output', precision='fp32', process_id=0, rec=True, rec_algorithm='CRNN', rec_batch_num=6, rec_char_dict_path='/home/aistudio/.data/webide/pip/lib/python3.7/site-packages/paddleocr/ppocr/utils/ppocr_keys_v1.txt', rec_image_shape='3, 32, 320', rec_model_dir='/home/aistudio/.paddleocr/whl/rec/ch/ch_PP-OCRv2_rec_infer', save_crop_res=False, save_log_path='./log_output/', scales=[8, 16, 32], show_log=True, structure_version='STRUCTURE', table_char_dict_path=None, table_char_type='en', table_max_len=488, table_model_dir=None, total_process_num=1, type='ocr', use_angle_cls=True, use_dilation=False, use_gpu=False, use_mp=False, use_onnx=False, use_pdserving=False, use_space_char=True, use_tensorrt=False, vis_font_path='./doc/fonts/simfang.ttf', warmup=False)
[2022/09/22 14:46:05] ppocr DEBUG: dt_boxes num : 4, elapse : 0.8229670524597168
[2022/09/22 14:46:05] ppocr DEBUG: cls num : 4, elapse : 0.19943690299987793
[2022/09/22 14:46:06] ppocr DEBUG: rec_res num : 4, elapse : 0.5032625198364258
[[[186.0, 87.0], [451.0, 103.0], [446.0, 186.0], [182.0, 170.0]], ('3942', 0.80900913)]
[[[64.0, 222.0], [151.0, 225.0], [150.0, 254.0], [63.0, 250.0]], ('SEPM', 0.68886095)]
[[[469.0, 233.0], [506.0, 233.0], [506.0, 282.0], [469.0, 282.0]], ('V', 0.9785347)]
[[[71.0, 252.0], [150.0, 255.0], [149.0, 276.0], [71.0, 273.0]], ('南自仪表', 0.9353922)]
算法优化
def write_to_csv(log_path, filename='', result=0.00, score=0, mode_head=True):
file = open(log_path, 'a+', encoding='utf-8', newline='')
csv_writer = csv.writer(file)
if mode_head == True:
csv_writer.writerow([f'filename', f'result', f'score'])
else:
csv_writer.writerow([filename, result, score])
file.close()
def get_bbox_area(box):
"""计算bbox的面积"""
bbox_area = (max(box[2]) - max(box[0])) * (max(box[3]) - max(box[1]))
return bbox_area
def quadArea(nodes):
"""计算多边形的面积"""
# 基于向量积计算不规则多边形的面积, 坐标点需要按顺序(逆时针或顺时针)选取
i_count = len(nodes)
area_temp = 0
for i in range(i_count):
area_temp += nodes[i][0] * nodes[(i+1) % i_count][1] - nodes[(i+1) % i_count][0] * nodes[i][1]
return abs(area_temp)
def bboxes_choose(boxes,txts,scores):
"""获取最大框体"""
area_list = []
for i in range(0, len(boxes)):
bx = boxes[i]
# area = get_bbox_area(bx)
area = quadArea(bx)
# print('bx:', bx, 'area:',area)
area_list.append(area)
if len(area_list) == 0:
index = 0
else:
index = area_list.index(max(area_list))
if len(boxes) == 0:
boxes = []
else:
boxes = [boxes[index]]
txts = [txts[index]]
scores = [scores[index]]
return boxes, txts, scores
def ocr_roi_det(img_path, font,save_path='./work/save/'):
"""OCR识别"""
result = ocr.ocr(img_path, cls=True)
# for line in result:
# print(line)
# 显示结果
from PIL import Image
image = Image.open(img_path).convert('RGB')
fileslist = img_path.split('/')
fname = fileslist[-1].split('.')[0]
# [[[151.0, 53.0], [277.0, 53.0], [277.0, 111.0], [151.0, 111.0]], ('00.2', 0.9423570036888123)]
boxes = [line[0] for line in result]
txts = [line[1][0] for line in result]
scores = [line[1][1] for line in result]
boxes, txts, scores = bboxes_choose(boxes, txts, scores)
# bs = nms(boxes, scores)
# print('bs:', bs)
im_show = draw_ocr(image, boxes, txts, scores, font_path=font)
im_show = Image.fromarray(im_show)
if not os.path.exists(save_path):
os.mkdir(save_path)
im_show.save(save_path + fname + '_result.jpg')
return txts[0], scores[0]
def all_test_det(path, log_path, font, save_path):
"""执行识别算法,并记录结果到csv"""
count = 0
img_list = []
img_ans_dic = {}
for filepath, dirnames, filenames in os.walk(path): # 在多级目录下找文件
for filename in filenames:
file_path = filepath + filename
# print('file_path:', file_path)
img_list.append(file_path)
global score
write_to_csv(log_path)
for i in tqdm(range(0, len(img_list)-1)):
img_roi = img_list[i]
# result, score = rec_display_roi(img_roi)
fileslist = img_roi.split('/')
fname = fileslist[-1].split('.')[0]
result, score = ocr_roi_det(img_roi, font,save_path)
print('result:', result, 'score:', score)
if result != '':
img_ans_dic[fname] = score
count += 1
else:
score = -1
img_ans_dic[fname] = score
continue
write_to_csv(log_path, fname, result, score,False)
print('count:', count)
print('dict_len:', len(img_ans_dic))
print('ans_dict:', img_ans_dic)
if __name__ == '__main__':
# Paddleocr目前支持的多语言语种可以通过修改lang参数进行切换
# 例如`ch`, `en`, `fr`, `german`, `korean`, `japan`
ocr = PaddleOCR(use_angle_cls=False, lang="en") # need to run only once to download and load model into memory
font = '/home/aistudio/work/font/simfang.ttf'
# ocr_roi_det(img_path, font)
log_path = '/home/aistudio/work/log/result.csv'
save_path = '/home/aistudio/work/save_result/'
test_path = '/home/aistudio/work/dataset/test/'
all_test_det(test_path, log_path, font ,save_path)
[2022/09/22 15:12:37] ppocr DEBUG: Namespace(alpha=1.0, benchmark=False, beta=1.0, cls_batch_num=6, cls_image_shape='3, 48, 192', cls_model_dir='/home/aistudio/.paddleocr/whl/cls/ch_ppocr_mobile_v2.0_cls_infer', cls_thresh=0.9, cpu_threads=10, crop_res_save_dir='./output', det=True, det_algorithm='DB', det_db_box_thresh=0.6, det_db_score_mode='fast', det_db_thresh=0.3, det_db_unclip_ratio=1.5, det_east_cover_thresh=0.1, det_east_nms_thresh=0.2, det_east_score_thresh=0.8, det_fce_box_type='poly', det_limit_side_len=960, det_limit_type='max', det_model_dir='/home/aistudio/.paddleocr/whl/det/en/en_ppocr_mobile_v2.0_det_infer', det_pse_box_thresh=0.85, det_pse_box_type='quad', det_pse_min_area=16, det_pse_scale=1, det_pse_thresh=0, det_sast_nms_thresh=0.2, det_sast_polygon=False, det_sast_score_thresh=0.5, draw_img_save_dir='./inference_results', drop_score=0.5, e2e_algorithm='PGNet', e2e_char_dict_path='./ppocr/utils/ic15_dict.txt', e2e_limit_side_len=768, e2e_limit_type='max', e2e_model_dir=None, e2e_pgnet_mode='fast', e2e_pgnet_score_thresh=0.5, e2e_pgnet_valid_set='totaltext', enable_mkldnn=False, fourier_degree=5, gpu_mem=500, help='==SUPPRESS==', image_dir=None, ir_optim=True, label_list=['0', '180'], label_map_path='./vqa/labels/labels_ser.txt', lang='en', layout_label_map=None, layout_path_model='lp://PubLayNet/ppyolov2_r50vd_dcn_365e_publaynet/config', max_batch_size=10, max_seq_length=512, max_text_length=25, min_subgraph_size=15, mode='structure', model_name_or_path=None, ocr_version='PP-OCRv2', output='./output', precision='fp32', process_id=0, rec=True, rec_algorithm='CRNN', rec_batch_num=6, rec_char_dict_path='/home/aistudio/.data/webide/pip/lib/python3.7/site-packages/paddleocr/ppocr/utils/en_dict.txt', rec_image_shape='3, 32, 320', rec_model_dir='/home/aistudio/.paddleocr/whl/rec/en/en_number_mobile_v2.0_rec_infer', save_crop_res=False, save_log_path='./log_output/', scales=[8, 16, 32], show_log=True, structure_version='STRUCTURE', table_char_dict_path=None, table_char_type='en', table_max_len=488, table_model_dir=None, total_process_num=1, type='ocr', use_angle_cls=False, use_dilation=False, use_gpu=False, use_mp=False, use_onnx=False, use_pdserving=False, use_space_char=True, use_tensorrt=False, vis_font_path='./doc/fonts/simfang.ttf', warmup=False)
0%| | 0/14 [00:00<?, ?it/s][A[A[A[A[A[A[A
[2022/09/22 15:12:38] ppocr WARNING: Since the angle classifier is not initialized, the angle classifier will not be uesd during the forward process
[2022/09/22 15:12:39] ppocr DEBUG: dt_boxes num : 15, elapse : 1.394296646118164
[2022/09/22 15:12:41] ppocr DEBUG: rec_res num : 15, elapse : 1.3982703685760498
7%|▋ | 1/14 [00:03<00:40, 3.09s/it][A[A[A[A[A[A[A
result: 482 score: 0.97532207
[2022/09/22 15:12:41] ppocr WARNING: Since the angle classifier is not initialized, the angle classifier will not be uesd during the forward process
[2022/09/22 15:12:42] ppocr DEBUG: dt_boxes num : 16, elapse : 1.394862413406372
[2022/09/22 15:12:44] ppocr DEBUG: rec_res num : 16, elapse : 1.2905313968658447
14%|█▍ | 2/14 [00:05<00:36, 3.03s/it][A[A[A[A[A[A[A
result: 480 score: 0.97698164
[2022/09/22 15:12:44] ppocr WARNING: Since the angle classifier is not initialized, the angle classifier will not be uesd during the forward process
[2022/09/22 15:12:45] ppocr DEBUG: dt_boxes num : 18, elapse : 1.4989678859710693
[2022/09/22 15:12:47] ppocr DEBUG: rec_res num : 18, elapse : 1.3994457721710205
21%|██▏ | 3/14 [00:09<00:33, 3.05s/it][A[A[A[A[A[A[A
result: 475 score: 0.9991196
[2022/09/22 15:12:47] ppocr WARNING: Since the angle classifier is not initialized, the angle classifier will not be uesd during the forward process
[2022/09/22 15:12:48] ppocr DEBUG: dt_boxes num : 4, elapse : 0.9958655834197998
[2022/09/22 15:12:48] ppocr DEBUG: rec_res num : 4, elapse : 0.29001855850219727
29%|██▊ | 4/14 [00:10<00:25, 2.56s/it][A[A[A[A[A[A[A
result: 15.6 score: 0.99385107
[2022/09/22 15:12:49] ppocr WARNING: Since the angle classifier is not initialized, the angle classifier will not be uesd during the forward process
[2022/09/22 15:12:50] ppocr DEBUG: dt_boxes num : 18, elapse : 1.2016396522521973
[2022/09/22 15:12:51] ppocr DEBUG: rec_res num : 18, elapse : 1.4024155139923096
36%|███▌ | 5/14 [00:13<00:23, 2.66s/it][A[A[A[A[A[A[A
result: 555 score: 0.9947159
[2022/09/22 15:12:51] ppocr WARNING: Since the angle classifier is not initialized, the angle classifier will not be uesd during the forward process
[2022/09/22 15:12:52] ppocr DEBUG: dt_boxes num : 4, elapse : 0.8874359130859375
[2022/09/22 15:12:53] ppocr DEBUG: rec_res num : 4, elapse : 0.29741787910461426
43%|████▎ | 6/14 [00:14<00:18, 2.28s/it][A[A[A[A[A[A[A
result: 394.2 score: 0.9848536
[2022/09/22 15:12:53] ppocr WARNING: Since the angle classifier is not initialized, the angle classifier will not be uesd during the forward process
[2022/09/22 15:12:53] ppocr DEBUG: dt_boxes num : 4, elapse : 0.3028900623321533
[2022/09/22 15:12:53] ppocr DEBUG: rec_res num : 4, elapse : 0.2898275852203369
50%|█████ | 7/14 [00:15<00:12, 1.81s/it][A[A[A[A[A[A[A
result: 260 score: 0.99791867
[2022/09/22 15:12:53] ppocr WARNING: Since the angle classifier is not initialized, the angle classifier will not be uesd during the forward process
[2022/09/22 15:12:54] ppocr DEBUG: dt_boxes num : 4, elapse : 0.30339860916137695
[2022/09/22 15:12:54] ppocr DEBUG: rec_res num : 4, elapse : 0.29735636711120605
57%|█████▋ | 8/14 [00:16<00:09, 1.51s/it][A[A[A[A[A[A[A
result: 10.2 score: 0.9172772
[2022/09/22 15:12:54] ppocr WARNING: Since the angle classifier is not initialized, the angle classifier will not be uesd during the forward process
[2022/09/22 15:12:56] ppocr DEBUG: dt_boxes num : 3, elapse : 1.5035269260406494
[2022/09/22 15:12:56] ppocr DEBUG: rec_res num : 3, elapse : 0.19791388511657715
result: 002 score: 0.9978652
64%|██████▍ | 9/14 [00:18<00:08, 1.65s/it][A[A[A[A[A[A[A
[2022/09/22 15:12:56] ppocr WARNING: Since the angle classifier is not initialized, the angle classifier will not be uesd during the forward process
[2022/09/22 15:12:57] ppocr DEBUG: dt_boxes num : 2, elapse : 0.4907827377319336
[2022/09/22 15:12:57] ppocr DEBUG: rec_res num : 2, elapse : 0.19646453857421875
71%|███████▏ | 10/14 [00:19<00:05, 1.40s/it][A[A[A[A[A[A[A
result: 00.0 score: 0.8969887
[2022/09/22 15:12:57] ppocr WARNING: Since the angle classifier is not initialized, the angle classifier will not be uesd during the forward process
[2022/09/22 15:12:58] ppocr DEBUG: dt_boxes num : 4, elapse : 1.2975883483886719
[2022/09/22 15:12:59] ppocr DEBUG: rec_res num : 4, elapse : 0.2966597080230713
79%|███████▊ | 11/14 [00:20<00:04, 1.52s/it][A[A[A[A[A[A[A
result: 894 score: 0.99809813
[2022/09/22 15:12:59] ppocr WARNING: Since the angle classifier is not initialized, the angle classifier will not be uesd during the forward process
[2022/09/22 15:12:59] ppocr DEBUG: dt_boxes num : 4, elapse : 0.39928150177001953
[2022/09/22 15:13:00] ppocr DEBUG: rec_res num : 4, elapse : 0.20896530151367188
86%|████████▌ | 12/14 [00:21<00:02, 1.33s/it][A[A[A[A[A[A[A
result: 001 score: 0.9889035
[2022/09/22 15:13:00] ppocr WARNING: Since the angle classifier is not initialized, the angle classifier will not be uesd during the forward process
[2022/09/22 15:13:01] ppocr DEBUG: dt_boxes num : 4, elapse : 0.9879066944122314
[2022/09/22 15:13:01] ppocr DEBUG: rec_res num : 4, elapse : 0.29622650146484375
93%|█████████▎| 13/14 [00:23<00:01, 1.35s/it][A[A[A[A[A[A[A
result: 393.9 score: 0.941982
[2022/09/22 15:13:01] ppocr WARNING: Since the angle classifier is not initialized, the angle classifier will not be uesd during the forward process
[2022/09/22 15:13:03] ppocr DEBUG: dt_boxes num : 16, elapse : 1.3959689140319824
[2022/09/22 15:13:04] ppocr DEBUG: rec_res num : 16, elapse : 1.198702335357666
100%|██████████| 14/14 [00:26<00:00, 1.82s/it]
result: 48.1. score: 0.94031876
[A[A[A[A[A[A[A
[A[A[A[A[A[A[A
count: 14
dict_len: 14
ans_dict: {'249553_steerPoint7_preset1257_20220917131810_v': 0.97532207, '58867_steerPoint7_preset1257_20220917161848_v': 0.97698164, '268997_steerPoint7_preset1257_20220917194818_v': 0.9991196, '72635_steerPoint12_preset1294_20220919123447_v': 0.99385107, '217734_steerPoint6_preset1256_20220917121753_v': 0.9947159, '133102_steerPoint5_preset1255_20220917221726_v': 0.9848536, '265968_steerPoint3_preset1241_20220918001329_v': 0.99791867, '333810_steerPoint3_preset1241_20220918170603_v': 0.9172772, '241047_steerPoint1_preset1229_20220919115945_v': 0.9978652, '274368_steerPoint3_preset1244_20220917184302_v': 0.8969887, '50375_steerPoint1_preset1232_20220918013638_v': 0.99809813, '71585_steerPoint9_preset1263_20220918191815_v': 0.9889035, '187206_steerPoint8_preset1262_20220917115119_v': 0.941982, '133444_steerPoint7_preset1257_20220917151834_v': 0.94031876}
结果分析
rs_img = '/home/aistudio/work/save_result/133102_steerPoint5_preset1255_20220917221726_v_result.jpg'
imshow_image(rs_img)
import pandas as pd
csv_path = '/home/aistudio/work/log/result.csv'
df_data = pd.read_csv(csv_path)
print(df_data.info())
print(df_data.describe())
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 14 entries, 0 to 13
Data columns (total 3 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 filename 14 non-null object
1 result 14 non-null object
2 score 14 non-null float64
dtypes: float64(1), object(2)
memory usage: 464.0+ bytes
None
score
count 14.000000
mean 0.971728
std 0.033699
min 0.896989
25% 0.950317
50% 0.986879
75% 0.997078
max 0.999120
sample_for_plotting = df_data[['filename','result','score']]
data_head = sample_for_plotting.head()
data_head
filename | result | score | |
---|---|---|---|
0 | 249553_steerPoint7_preset1257_20220917131810_v | 482 | 0.975322 |
1 | 58867_steerPoint7_preset1257_20220917161848_v | 480 | 0.976982 |
2 | 268997_steerPoint7_preset1257_20220917194818_v | 475 | 0.999120 |
3 | 72635_steerPoint12_preset1294_20220919123447_v | 15.6 | 0.993851 |
4 | 217734_steerPoint6_preset1256_20220917121753_v | 555 | 0.994716 |
总结
遇到一个算法识别问题的时候,要学会利用掌握的知识和经验,将问题进行拆解与转化。
并且要考虑到实际应用场景下的问题,有些步骤和条件需不需要?是否只能用深度学习的方法?
能不能用其他方式来进行某个方面的辅助,这些都是值得去思考和研究的问题。
此文章为搬运
原项目链接
更多推荐
所有评论(0)