Skip to content

Commit

Permalink
fix:t_recognizer TypeError: 'super' object is not callable (#4404)
Browse files Browse the repository at this point in the history
### What problem does this PR solve?

[Bug]: layout recognizer failed for wrong boxes class type #4230
(#4230)

### Type of change

- [✅ ] Bug Fix (non-breaking change which fixes an issue)

---------

Co-authored-by: youzhiqiang <[email protected]>
Co-authored-by: Kevin Hu <[email protected]>
  • Loading branch information
3 people authored Jan 8, 2025
1 parent 5e64d79 commit b7ce4e7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 2 additions & 0 deletions deepdoc/vision/layout_recognizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ def findLayout(ty):
ocr_res = [b for b in ocr_res if b["text"].strip() not in garbag_set]
return ocr_res, page_layout

def forward(self, image_list, thr=0.7, batch_size=16):
return super().__call__(image_list, thr, batch_size)

class LayoutRecognizer4YOLOv10(LayoutRecognizer):
labels = [
Expand Down
7 changes: 3 additions & 4 deletions deepdoc/vision/t_recognizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
'../../')))

from deepdoc.vision.seeit import draw_box
from deepdoc.vision import LayoutRecognizer, TableStructureRecognizer, OCR, init_in_out, Recognizer
from deepdoc.vision import LayoutRecognizer, TableStructureRecognizer, OCR, init_in_out
import argparse
import re
import numpy as np
Expand All @@ -33,9 +33,8 @@ def main(args):
images, outputs = init_in_out(args)
if args.mode.lower() == "layout":
detr = LayoutRecognizer("layout")
layouts = super(Recognizer, detr)(images, thr=float(args.threshold))
layouts = detr.forward(images, thr=float(args.threshold))
if args.mode.lower() == "tsr":
labels = TableStructureRecognizer.labels
detr = TableStructureRecognizer()
ocr = OCR()
layouts = detr(images, thr=float(args.threshold))
Expand All @@ -50,7 +49,7 @@ def main(args):
"bbox": [t["x0"], t["top"], t["x1"], t["bottom"]],
"score": t["score"]
} for t in lyt]
img = draw_box(images[i], lyt, labels, float(args.threshold))
img = draw_box(images[i], lyt, detr.labels, float(args.threshold))
img.save(outputs[i], quality=95)
logging.info("save result to: " + outputs[i])

Expand Down

0 comments on commit b7ce4e7

Please sign in to comment.