File size: 753 Bytes
256a159
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from typing import Any

import torch


class QwenVLBasePostProcessor:
    """Post processor for Qwen-VL-Base."""

    def __init__(self) -> None:
        pass

    def __call__(self, pred: torch.tensor, tokenizer: Any,
                 input_len: int) -> str:
        response = self.tokenizer.decode(pred)[input_len:]
        response = response.replace('<|endoftext|>', '').strip()
        return response


class QwenVLChatVSRPostProcessor:
    """VSR post processor for Qwen-VL-Chat."""

    def __init__(self) -> None:
        pass

    def __call__(self, response: str) -> str:
        if 'yes' in response.lower():
            return 'yes'
        elif 'no' in response.lower():
            return 'no'
        else:
            return 'unknown'