Upload processing_kosmos2.py
Browse files- processing_kosmos2.py +1 -17
processing_kosmos2.py
CHANGED
@@ -544,23 +544,7 @@ def extract_entities_with_patch_indices(text):
|
|
544 |
entity = f"<patch_index_{bbox[0]}><patch_index_{bbox[1]}>"
|
545 |
entities_with_patch_indices.append((entity, span, [bbox]))
|
546 |
|
547 |
-
|
548 |
-
new_text = text.strip()
|
549 |
-
|
550 |
-
leading_spaces = text - text.lstrip(text)
|
551 |
-
|
552 |
-
new_entities = []
|
553 |
-
for entity_name, (start, end), bboxes in entities:
|
554 |
-
|
555 |
-
start = start - leading_spaces + (entity_name.lstrip(entity_name))
|
556 |
-
end = end - leading_spaces - (entity_name.rstrip(entity_name))
|
557 |
-
entity_name = entity_name.strip()
|
558 |
-
|
559 |
-
new_entities.append((entity_name, (start, end), bboxes))
|
560 |
-
|
561 |
-
return new_text, new_entities
|
562 |
-
|
563 |
-
return cleanup_spaces(entities_with_patch_indices)
|
564 |
|
565 |
|
566 |
# TODO: Be careful
|
|
|
544 |
entity = f"<patch_index_{bbox[0]}><patch_index_{bbox[1]}>"
|
545 |
entities_with_patch_indices.append((entity, span, [bbox]))
|
546 |
|
547 |
+
return entities_with_patch_indices
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
548 |
|
549 |
|
550 |
# TODO: Be careful
|