python - PaddleOCR rec_model_dir gives incorrect text results – Why does lang='en' work but not my model? - Stac

my problem is that I dont understand why paddleocr gives me weird text recognition results if I put a m

my problem is that I dont understand why paddleocr gives me weird text recognition results if I put a model in PaddleOCR(rec_model_dir="[modelPath]") . My goal is to use a custom fine tuned model on pictures so I get the best possible recognition result. So I tried to use the "en_PP-OCRv4_rec_infer" model and put the path to the folder that contains the "inference.pdiparams, inference.pdiparams.info, inference.pdmodel" files into the [modelPath] gap for rec_model_dir. I got weird results like "7????????7:???"or "7消先7:昏" for a picture that clearly doesnt show that text (I tried more pictures and I got the same problem with also weird results similar to this one). After that I found out that if I do PaddleOCR(lang="en") it uses the same model, but it is working fine. -> The result is "LV-LOW" But I need to use rec_model_dir for my custom model. whats the problem that I cant use rec_model_dir ? Here is my Code:

import cv2
from paddleocr import PaddleOCR

image_path = r"./Picture.jpg"
image_path.replace("\\", "/")

model_path = r"./model" 
model_path.replace("\\", "/")

def extract_text(image_path, model_path):
    ocr_model = PaddleOCR(rec_model_dir= model_path, det=False, show_log=False, use_angle_cls=True)
    image = cv2.imread(image_path)

    result = ocr_model.ocr(image, cls=True)
    text_detected = ", ".join(row[1][0] for row in result[0]) if result and result[0] else "NOINFO"
    print(text_detected)

extract_text(image_path, model_path)

Used Picture

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744129528a4559773.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信