def _compute_high_detail_tokens()

in aidial_adapter_openai/utils/image_tokenizer.py [0:0]


    def _compute_high_detail_tokens(self, width: int, height: int) -> int:
        # Fit into 2048x2048 box
        width, height = _fit_longest(width, height, 2048)

        # Scale down so the shortest side is 768 pixels
        width, height = _fit_shortest(width, height, 768)

        # Calculate the number of 512-pixel tiles required
        cols = math.ceil(width / 512)
        rows = math.ceil(height / 512)

        return (self.tokens_per_tile * cols * rows) + self.low_detail_tokens