Can you post the complete "DET_RE" regex pattern from the post-processing script?

#17
by rontonie - opened

def remove_det(raw: str) -> str:
"""
Strip <|det|>type [bbox]<|/det|> markers, group lines belonging to the
same block with \n, and separate different blocks with \n\n.
"""
blocks = []
cur = None
for line in raw.splitlines():
line = line.rstrip()
if not line:
continue
m = DET_RE.match(line)
if m:
category, content = m.group(1).strip(), m.group(2).strip()
if category == 'image':
continue
if cur is not None:
blocks.append(cur)
cur = [content] if content else []
continue
if cur is None:
cur = []
cur.append(line)
if cur is not None:
blocks.append(cur)
text = '\n\n'.join('\n'.join(b) for b in blocks).strip()
return text

Need the "DET_RE" pattern for this please.

BAIDU org

Thanks, we have completed the post-processing script!
DET_RE = re.compile(r'<|det|>([^<\s]+)(?:\s[[^]]])?\s<|/det|>(.)', re.DOTALL)

Sign up or log in to comment