瀏覽代碼

fix:t_recognizer TypeError: 'super' object is not callable (#4404)

### What problem does this PR solve?

[Bug]: layout recognizer failed for wrong boxes class type #4230
(https://github.com/infiniflow/ragflow/issues/4230)

### Type of change

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

---------

Co-authored-by: youzhiqiang <zhiqiang.you@aminer.com>
Co-authored-by: Kevin Hu <kevinhu.sh@gmail.com>
tags/v0.16.0
Zhi-Qiang You 9 月之前
父節點
當前提交
b7ce4e7e62
沒有連結到貢獻者的電子郵件帳戶。
共有 2 個檔案被更改,包括 5 行新增4 行删除
  1. 2
    0
      deepdoc/vision/layout_recognizer.py
  2. 3
    4
      deepdoc/vision/t_recognizer.py

+ 2
- 0
deepdoc/vision/layout_recognizer.py 查看文件

ocr_res = [b for b in ocr_res if b["text"].strip() not in garbag_set] ocr_res = [b for b in ocr_res if b["text"].strip() not in garbag_set]
return ocr_res, page_layout 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): class LayoutRecognizer4YOLOv10(LayoutRecognizer):
labels = [ labels = [

+ 3
- 4
deepdoc/vision/t_recognizer.py 查看文件

'../../'))) '../../')))


from deepdoc.vision.seeit import draw_box 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 argparse
import re import re
import numpy as np import numpy as np
images, outputs = init_in_out(args) images, outputs = init_in_out(args)
if args.mode.lower() == "layout": if args.mode.lower() == "layout":
detr = LayoutRecognizer("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": if args.mode.lower() == "tsr":
labels = TableStructureRecognizer.labels
detr = TableStructureRecognizer() detr = TableStructureRecognizer()
ocr = OCR() ocr = OCR()
layouts = detr(images, thr=float(args.threshold)) layouts = detr(images, thr=float(args.threshold))
"bbox": [t["x0"], t["top"], t["x1"], t["bottom"]], "bbox": [t["x0"], t["top"], t["x1"], t["bottom"]],
"score": t["score"] "score": t["score"]
} for t in lyt] } 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) img.save(outputs[i], quality=95)
logging.info("save result to: " + outputs[i]) logging.info("save result to: " + outputs[i])



Loading…
取消
儲存