Rename method
Browse files- README.md +2 -2
- processing_kosmos2.py +1 -1
README.md
CHANGED
@@ -49,13 +49,13 @@ generated_ids = model.generate(
|
|
49 |
generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
50 |
|
51 |
# Specify `cleanup_and_extract=False` in order to see the raw model generation.
|
52 |
-
processed_text = processor.
|
53 |
|
54 |
print(processed_text)
|
55 |
# `<grounding> An image of<phrase> a snowman</phrase><object><patch_index_0044><patch_index_0863></object> warming himself by<phrase> a fire</phrase><object><patch_index_0005><patch_index_0911></object>.`
|
56 |
|
57 |
# By default, the generated text is cleanup and the entities are extracted.
|
58 |
-
processed_text, entities = processor.
|
59 |
|
60 |
print(processed_text)
|
61 |
# `An image of a snowman warming himself by a fire.`
|
|
|
49 |
generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
50 |
|
51 |
# Specify `cleanup_and_extract=False` in order to see the raw model generation.
|
52 |
+
processed_text = processor.post_process_generation(generated_text, cleanup_and_extract=False)
|
53 |
|
54 |
print(processed_text)
|
55 |
# `<grounding> An image of<phrase> a snowman</phrase><object><patch_index_0044><patch_index_0863></object> warming himself by<phrase> a fire</phrase><object><patch_index_0005><patch_index_0911></object>.`
|
56 |
|
57 |
# By default, the generated text is cleanup and the entities are extracted.
|
58 |
+
processed_text, entities = processor.post_process_generation(generated_text)
|
59 |
|
60 |
print(processed_text)
|
61 |
# `An image of a snowman warming himself by a fire.`
|
processing_kosmos2.py
CHANGED
@@ -336,7 +336,7 @@ class Kosmos2Processor(ProcessorMixin):
|
|
336 |
"""
|
337 |
return self.tokenizer.decode(*args, **kwargs)
|
338 |
|
339 |
-
def
|
340 |
|
341 |
caption = text.split("</image>")[-1]
|
342 |
if cleanup_and_extract:
|
|
|
336 |
"""
|
337 |
return self.tokenizer.decode(*args, **kwargs)
|
338 |
|
339 |
+
def post_process_generation(self, text, cleanup_and_extract=True):
|
340 |
|
341 |
caption = text.split("</image>")[-1]
|
342 |
if cleanup_and_extract:
|