EasyOCR icon indicating copy to clipboard operation
EasyOCR copied to clipboard

Missing Confidence Score in Paragraph Mode

Open devalnor opened this issue 1 year ago • 4 comments

When extract text from images in paragraph mode, the confidence scores for the detected text are not included in the results.

Only bbox and text are in results.

Any idea of how to solve this?

devalnor avatar Jul 17 '24 20:07 devalnor

This is not possible to get confidence, because it combines a few results with different confidence

fiksii-copilot avatar Jul 25 '24 18:07 fiksii-copilot

In EasyOCR, when extracting text from images in paragraph mode, the confidence scores are typically included in the results. However, if they are missing, it might be due to the version of EasyOCR you're using or the specific settings and parameters passed to the readtext function.

Possible solution:-

  1. Update the latest version of OCR
  2. Using the detail Parameter: The readtext method in EasyOCR has a detail parameter that controls the level of detail in the output. By setting detail=1, you should get confidence scores along with the bounding boxes and text.
import easyocr

# Initialize the reader
reader = easyocr.Reader(['en'], gpu=True)

# Read text from the image
results = reader.readtext('path_to_image', detail=1, paragraph=True)

# Print results
for result in results:
    bbox, text, confidence = result
    print(f"Bounding Box: {bbox}, Text: {text}, Confidence: {confidence}")
  1. Verify the output structure
  2. Check for Paragraph Mode Limitations: If you're specifically working in paragraph mode and confidence scores are not included, it might be due to how the paragraph mode processes text.

Hope this helps Thanks

Siddharth-Latthe-07 avatar Jul 27 '24 13:07 Siddharth-Latthe-07

I have completely the same problem!

EasyOCR version - 1.7.2

    results = reader.readtext(
        img,
        allowlist='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 -',
        height_ths=0.6,
        width_ths=0.6,
        ycenter_ths=0.5,
        detail=1, 
        paragraph=True
    )
    logger.info(f"results={results}")

logged message

results=[[[[97, 45], [854, 45], [854, 356], [97, 356]], 'SOME DETECTED TEXT']]

KovaliovNA avatar Apr 17 '25 10:04 KovaliovNA

In EasyOCR, when extracting text from images in paragraph mode, the confidence scores are typically included in the results. However, if they are missing, it might be due to the version of EasyOCR you're using or the specific settings and parameters passed to the readtext function.

Possible solution:-

1. Update the latest version of OCR

2. Using the detail Parameter:
   The readtext method in EasyOCR has a `detail` parameter that controls the level of detail in the output. By setting `detail=1`, you should get confidence scores along with the bounding boxes and text.
import easyocr

# Initialize the reader
reader = easyocr.Reader(['en'], gpu=True)

# Read text from the image
results = reader.readtext('path_to_image', detail=1, paragraph=True)

# Print results
for result in results:
    bbox, text, confidence = result
    print(f"Bounding Box: {bbox}, Text: {text}, Confidence: {confidence}")
3. Verify the output structure

4. Check for Paragraph Mode Limitations:
   If you're specifically working in paragraph mode and confidence scores are not included, it might be due to how the paragraph mode processes text.

Hope this helps Thanks

Is this AI generated ?

brvier avatar Apr 29 '25 14:04 brvier