OpenCompass/opencompass/multimodal/models/llava/post_processor.py
Yike Yuan 3f601f420b
[Feat] Support public dataset of visualglm and llava. (#265)
* [Feat] Add public dataset support of VisualGLM.

* [Feat] Refactor LLaVA.

* [Feat] Add public dataset support of LlaVA.

* [Fix] Add  arg.
2023-08-25 15:44:32 +08:00

29 lines
834 B
Python

class LLaVABasePostProcessor:
"""Base post processor for LLaVA on MMBench."""
def __init__(self) -> None:
pass
def __call__(self, outputs: str, stop_str: str) -> str:
outputs = outputs.strip()
if outputs.endswith(stop_str):
outputs = outputs[:-len(stop_str)]
output_text = outputs.strip()
return output_text
class LLaVAVSRPostProcessor(LLaVABasePostProcessor):
"""VSR post processor for LLaVA on MMBench."""
def __init__(self) -> None:
super().__init__()
def __call__(self, outputs: str, stop_str: str) -> str:
output_text = super().__call__(outputs, stop_str)
if 'yes' in output_text.lower():
return 'yes'
elif 'no' in output_text.lower():
return 'no'
else:
return 'unknown'