1.修改文本检测模型和文本识别模型移动端配置文件.\n2.测试ocr移动端的模型
This commit is contained in:
parent
a984e75e55
commit
eb44f05744
@ -3,10 +3,14 @@ from paddleocr import PaddleOCR
|
||||
ocr = PaddleOCR(
|
||||
# 文本检测模型地址
|
||||
# text_detection_model_dir = "/home/admin-root/haotian/康达瑞贝斯机器狗/ocr_model/PP-OCRv5_server_det",
|
||||
text_detection_model_dir='/home/admin-root/haotian/康达瑞贝斯机器狗/PaddleOCR-3.1.0/output/PP-OCRv5_server_det_infer_20250814',
|
||||
# text_detection_model_dir='/home/admin-root/haotian/康达瑞贝斯机器狗/PaddleOCR-3.1.0/output/PP-OCRv5_server_det_infer_20250814',
|
||||
text_detection_model_dir="/home/admin-root/haotian/康达瑞贝斯机器狗/PaddleOCR-3.1.0/output/PP-OCRv5_mobile_det_infer_20250820",
|
||||
text_detection_model_name = "PP-OCRv5_mobile_det", # 名称要和模型保持一致
|
||||
# 文本识别模型地址
|
||||
# text_recognition_model_dir = "/home/admin-root/haotian/康达瑞贝斯机器狗/ocr_model/PP-OCRv5_server_rec",
|
||||
text_recognition_model_dir='/home/admin-root/haotian/康达瑞贝斯机器狗/PaddleOCR-3.1.0/output/PP-OCRv5_server_rec_infer_20250815',
|
||||
# text_recognition_model_dir='/home/admin-root/haotian/康达瑞贝斯机器狗/PaddleOCR-3.1.0/output/PP-OCRv5_server_rec_infer_20250815',
|
||||
text_recognition_model_dir='/home/admin-root/haotian/康达瑞贝斯机器狗/PaddleOCR-3.1.0/output/PP-OCRv5_mobile_rec_infer_20250820',
|
||||
text_recognition_model_name = 'PP-OCRv5_mobile_rec',
|
||||
use_doc_orientation_classify=False,
|
||||
use_doc_unwarping=False,
|
||||
use_textline_orientation=False) # 文本检测+文本识别
|
||||
@ -18,12 +22,12 @@ ocr = PaddleOCR(
|
||||
# use_doc_orientation_classify=False,
|
||||
# use_doc_unwarping=False,
|
||||
# use_textline_orientation=False) # 更换 PP-OCRv5_mobile 模型
|
||||
result = ocr.predict("/home/admin-root/haotian/康达瑞贝斯机器狗/data_image/001读表图片/3aee64cc1f90d93a5a45979f7b17cb4b_frame_001460.jpg")
|
||||
result = ocr.predict("/home/admin-root/haotian/康达瑞贝斯机器狗/data_image/001读表图片/632e474452d560edd7004f745319ff00_frame_000730.jpg")
|
||||
|
||||
# print(result[0].shape)
|
||||
# for res in result:
|
||||
# res.print()
|
||||
for res in result:
|
||||
res.print()
|
||||
|
||||
# # 输出文件夹
|
||||
# res.save_to_img("output")
|
||||
# 输出文件夹
|
||||
res.save_to_img("output")
|
||||
# res.save_to_json("output")
|
||||
@ -12,7 +12,7 @@ Global:
|
||||
- 1500
|
||||
cal_metric_during_train: false
|
||||
checkpoints:
|
||||
pretrained_model: https://paddleocr.bj.bcebos.com/pretrained/PPLCNetV3_x0_75_ocr_det.pdparams
|
||||
pretrained_model: /home/admin-root/haotian/康达瑞贝斯机器狗/ocr_model/PP-OCRv5_mobile_det_pretrained/PP-OCRv5_mobile_det_pretrained.pdparams
|
||||
save_inference_dir: null
|
||||
use_visualdl: false
|
||||
infer_img: doc/imgs_en/img_10.jpg
|
||||
@ -71,9 +71,9 @@ Metric:
|
||||
Train:
|
||||
dataset:
|
||||
name: SimpleDataSet
|
||||
data_dir: ./train_data/icdar2015/text_localization/
|
||||
data_dir: /home/admin-root/haotian/康达瑞贝斯机器狗/ocr_dataset
|
||||
label_file_list:
|
||||
- ./train_data/icdar2015/text_localization/train_icdar2015_label.txt
|
||||
- /home/admin-root/haotian/康达瑞贝斯机器狗/ocr_dataset/001读表图片/Label.txt
|
||||
ratio_list: [1.0]
|
||||
transforms:
|
||||
- DecodeImage:
|
||||
@ -139,9 +139,9 @@ Train:
|
||||
Eval:
|
||||
dataset:
|
||||
name: SimpleDataSet
|
||||
data_dir: ./train_data/icdar2015/text_localization/
|
||||
data_dir: /home/admin-root/haotian/康达瑞贝斯机器狗/ocr_dataset
|
||||
label_file_list:
|
||||
- ./train_data/icdar2015/text_localization/test_icdar2015_label.txt
|
||||
- /home/admin-root/haotian/康达瑞贝斯机器狗/ocr_dataset/001读表图片/Label.txt
|
||||
transforms:
|
||||
- DecodeImage:
|
||||
img_mode: BGR
|
||||
|
||||
@ -9,7 +9,7 @@ Global:
|
||||
save_epoch_step: 10
|
||||
eval_batch_step: [0, 2000]
|
||||
cal_metric_during_train: true
|
||||
pretrained_model:
|
||||
pretrained_model: /home/admin-root/haotian/康达瑞贝斯机器狗/ocr_model/PP-OCRv5_mobile_rec_pretrained/PP-OCRv5_mobile_rec_pretrained.pdparams
|
||||
checkpoints:
|
||||
save_inference_dir:
|
||||
use_visualdl: false
|
||||
@ -77,10 +77,10 @@ Train:
|
||||
dataset:
|
||||
name: MultiScaleDataSet
|
||||
ds_width: false
|
||||
data_dir: ./train_data/
|
||||
data_dir: /home/admin-root/haotian/康达瑞贝斯机器狗/ocr_dataset/001读表图片
|
||||
ext_op_transform_idx: 1
|
||||
label_file_list:
|
||||
- ./train_data/train_list.txt
|
||||
- /home/admin-root/haotian/康达瑞贝斯机器狗/ocr_dataset/001读表图片/rec_gt.txt
|
||||
transforms:
|
||||
- DecodeImage:
|
||||
img_mode: BGR
|
||||
@ -103,7 +103,7 @@ Train:
|
||||
sampler:
|
||||
name: MultiScaleSampler
|
||||
scales: [[320, 32], [320, 48], [320, 64]]
|
||||
first_bs: &bs 128
|
||||
first_bs: &bs 64
|
||||
fix_bs: false
|
||||
divided_factor: [8, 16] # w, h
|
||||
is_training: True
|
||||
@ -115,9 +115,9 @@ Train:
|
||||
Eval:
|
||||
dataset:
|
||||
name: SimpleDataSet
|
||||
data_dir: ./train_data
|
||||
data_dir: /home/admin-root/haotian/康达瑞贝斯机器狗/ocr_dataset/001读表图片
|
||||
label_file_list:
|
||||
- ./train_data/val_list.txt
|
||||
- /home/admin-root/haotian/康达瑞贝斯机器狗/ocr_dataset/001读表图片/rec_gt.txt
|
||||
transforms:
|
||||
- DecodeImage:
|
||||
img_mode: BGR
|
||||
|
||||
@ -1,84 +0,0 @@
|
||||
{
|
||||
"input_path": "/home/admin-root/haotian/康达瑞贝斯机器狗/data_image/001读表图片/3aee64cc1f90d93a5a45979f7b17cb4b_frame_001460.jpg",
|
||||
"page_index": null,
|
||||
"model_settings": {
|
||||
"use_doc_preprocessor": true,
|
||||
"use_textline_orientation": false
|
||||
},
|
||||
"doc_preprocessor_res": {
|
||||
"input_path": null,
|
||||
"page_index": null,
|
||||
"model_settings": {
|
||||
"use_doc_orientation_classify": false,
|
||||
"use_doc_unwarping": false
|
||||
},
|
||||
"angle": -1
|
||||
},
|
||||
"dt_polys": [
|
||||
[
|
||||
[
|
||||
813,
|
||||
204
|
||||
],
|
||||
[
|
||||
868,
|
||||
204
|
||||
],
|
||||
[
|
||||
868,
|
||||
240
|
||||
],
|
||||
[
|
||||
813,
|
||||
240
|
||||
]
|
||||
]
|
||||
],
|
||||
"text_det_params": {
|
||||
"limit_side_len": 64,
|
||||
"limit_type": "min",
|
||||
"thresh": 0.3,
|
||||
"max_side_limit": 4000,
|
||||
"box_thresh": 0.6,
|
||||
"unclip_ratio": 1.5
|
||||
},
|
||||
"text_type": "general",
|
||||
"textline_orientation_angles": [
|
||||
-1
|
||||
],
|
||||
"text_rec_score_thresh": 0.0,
|
||||
"rec_texts": [
|
||||
"7.7C"
|
||||
],
|
||||
"rec_scores": [
|
||||
0.9201567769050598
|
||||
],
|
||||
"rec_polys": [
|
||||
[
|
||||
[
|
||||
813,
|
||||
204
|
||||
],
|
||||
[
|
||||
868,
|
||||
204
|
||||
],
|
||||
[
|
||||
868,
|
||||
240
|
||||
],
|
||||
[
|
||||
813,
|
||||
240
|
||||
]
|
||||
]
|
||||
],
|
||||
"rec_boxes": [
|
||||
[
|
||||
813,
|
||||
204,
|
||||
868,
|
||||
240
|
||||
]
|
||||
]
|
||||
}
|
||||
@ -16,8 +16,12 @@ DB_POOL_RECYCLE= 1800
|
||||
TEXT_DETECTION_MODEL_DIR= '/home/admin-root/haotian/康达瑞贝斯机器狗/PaddleOCR-3.1.0/output/PP-OCRv5_server_det_infer_20250814'
|
||||
TEXT_RECONGNITION_MODEL_DIR= '/home/admin-root/haotian/康达瑞贝斯机器狗/PaddleOCR-3.1.0/output/PP-OCRv5_server_rec_infer_20250815'
|
||||
|
||||
TEXT_DETECTION_MODEL_ONNX_DIR='/home/admin-root/haotian/康达瑞贝斯机器狗/det_shape_20250814.onnx'
|
||||
TEXT_RECONGNITION_MODEL_ONNX_DIR='/home/admin-root/haotian/康达瑞贝斯机器狗/rec_shape_20250815.onnx'
|
||||
# TEXT_DETECTION_MODEL_ONNX_DIR='/home/admin-root/haotian/康达瑞贝斯机器狗/det_shape_20250814.onnx'
|
||||
# TEXT_RECONGNITION_MODEL_ONNX_DIR='/home/admin-root/haotian/康达瑞贝斯机器狗/rec_shape_20250815.onnx'
|
||||
|
||||
TEXT_DETECTION_MODEL_ONNX_DIR='/home/admin-root/haotian/康达瑞贝斯机器狗/det_mobile_14_shape.onnx'
|
||||
TEXT_RECONGNITION_MODEL_ONNX_DIR='/home/admin-root/haotian/康达瑞贝斯机器狗/rec_mobile_14_shape.onnx'
|
||||
|
||||
#---------------------------ocr配置end----------------------------------------
|
||||
|
||||
|
||||
|
||||
@ -23,8 +23,11 @@ class DataBaseSettings(BaseSettings):
|
||||
class OCRSettings(BaseException):
|
||||
TEXT_DETECTION_MODEL_DIR: str = '/home/admin-root/haotian/康达瑞贝斯机器狗/PaddleOCR-3.1.0/output/PP-OCRv5_server_det_infer_20250814'
|
||||
TEXT_RECONGNITION_MODEL_DIR: str = '/home/admin-root/haotian/康达瑞贝斯机器狗/PaddleOCR-3.1.0/output/PP-OCRv5_server_rec_infer_20250815'
|
||||
TEXT_DETECTION_MODEL_ONNX_DIR: str ='/home/admin-root/haotian/康达瑞贝斯机器狗/det_shape_20250814.onnx'
|
||||
TEXT_RECONGNITION_MODEL_ONNX_DIR: str ='/home/admin-root/haotian/康达瑞贝斯机器狗/rec_shape_20250815.onnx'
|
||||
# TEXT_DETECTION_MODEL_ONNX_DIR: str ='/home/admin-root/haotian/康达瑞贝斯机器狗/det_shape_20250814.onnx'
|
||||
# TEXT_RECONGNITION_MODEL_ONNX_DIR: str ='/home/admin-root/haotian/康达瑞贝斯机器狗/rec_shape_20250815.onnx'
|
||||
|
||||
TEXT_DETECTION_MODEL_ONNX_DIR='/home/admin-root/haotian/康达瑞贝斯机器狗/det_mobile_14_shape.onnx'
|
||||
TEXT_RECONGNITION_MODEL_ONNX_DIR='/home/admin-root/haotian/康达瑞贝斯机器狗/rec_mobile_14_shape.onnx'
|
||||
|
||||
class YoloV8Settings(BaseException):
|
||||
YOLOV8_MODEL_DIR: str = '/home/admin-root/haotian/康达瑞贝斯机器狗/YoloV8Obj/dataset_20250819/train2/weights/best.pt'
|
||||
|
||||
@ -82,13 +82,13 @@ if __name__ == "__main__":
|
||||
# 测试图片路径,请根据实际情况修改
|
||||
# test_image_path = "/home/admin-root/haotian/康达瑞贝斯机器狗/data_image/001读表图片/2c7cc83019e7388a7041101da92c9829_frame_000000.jpg"
|
||||
|
||||
# #---------------------------------------测试ocr-----------------------------------------
|
||||
# test_image_path = "/home/admin-root/haotian/康达瑞贝斯机器狗/data_image/001读表图片/632e474452d560edd7004f745319ff00_frame_000730.jpg"
|
||||
#---------------------------------------测试ocr-----------------------------------------
|
||||
test_image_path = "/home/admin-root/haotian/康达瑞贝斯机器狗/data_image/001读表图片/632e474452d560edd7004f745319ff00_frame_000730.jpg"
|
||||
|
||||
# api_url="http://10.0.0.202:12342/api/v1/ocr_onnx_from_base64"
|
||||
# # 调用测试函数
|
||||
# test_ocr_api(test_image_path, api_url)
|
||||
# #---------------------------------------测试ocrender-----------------------------------------
|
||||
api_url="http://10.0.0.202:12342/api/v1/ocr_onnx_from_base64"
|
||||
# 调用测试函数
|
||||
test_ocr_api(test_image_path, api_url)
|
||||
#---------------------------------------测试ocrender-----------------------------------------
|
||||
|
||||
# # -----------------------------------------测试yolov8 侵占消防区域检测-----------------------------------------
|
||||
# test_image_path = "/home/admin-root/haotian/康达瑞贝斯机器狗/YoloV8Obj/dataset_20250819/train/images/1e4c75b76e531606e2adc491a8f09ae8_frame_000000.jpg"
|
||||
@ -98,10 +98,10 @@ if __name__ == "__main__":
|
||||
# #-----------------------------------------测试yolov8 侵占消防区域检测 end-----------------------------------------
|
||||
|
||||
|
||||
#-----------------------------------------测试yolov8 灭火器检测-----------------------------------------
|
||||
test_image_path = "/home/admin-root/haotian/康达瑞贝斯机器狗/YoloV8Obj/dataset_20250819/train/images/ce81420a27cdaff14fe42f967eaa49a3_frame_001060.jpg"
|
||||
# test_image_path = "/home/admin-root/haotian/康达瑞贝斯机器狗/YoloV8Obj/dataset_20250819/train/images/1e4c75b76e531606e2adc491a8f09ae8_frame_000120.jpg"
|
||||
# test_image_path = "/home/admin-root/haotian/康达瑞贝斯机器狗/YoloV8Obj/dataset_20250819/train/images/1e4c75b76e531606e2adc491a8f09ae8_frame_000120.jpg"
|
||||
api_url = "http://10.0.0.202:12342/api/v1/detect_from_base64_1"
|
||||
test_detect(test_image_path, api_url=api_url)
|
||||
#-----------------------------------------测试yolov8 灭火器检测 end-----------------------------------------
|
||||
# #-----------------------------------------测试yolov8 灭火器检测-----------------------------------------
|
||||
# test_image_path = "/home/admin-root/haotian/康达瑞贝斯机器狗/YoloV8Obj/dataset_20250819/train/images/ce81420a27cdaff14fe42f967eaa49a3_frame_001060.jpg"
|
||||
# # test_image_path = "/home/admin-root/haotian/康达瑞贝斯机器狗/YoloV8Obj/dataset_20250819/train/images/1e4c75b76e531606e2adc491a8f09ae8_frame_000120.jpg"
|
||||
# # test_image_path = "/home/admin-root/haotian/康达瑞贝斯机器狗/YoloV8Obj/dataset_20250819/train/images/1e4c75b76e531606e2adc491a8f09ae8_frame_000120.jpg"
|
||||
# api_url = "http://10.0.0.202:12342/api/v1/detect_from_base64_1"
|
||||
# test_detect(test_image_path, api_url=api_url)
|
||||
# #-----------------------------------------测试yolov8 灭火器检测 end-----------------------------------------
|
||||
Loading…
Reference in New Issue
Block a user