def __call__()

in docker_images/timm/app/pipelines/image_classification.py [0:0]


    def __call__(self, inputs: Image.Image) -> List[Dict[str, Any]]:
        """
        Args:
            inputs (:obj:`PIL.Image`):
                The raw image representation as PIL.
                No transformation made whatsoever from the input. Make all necessary transformations here.
        Return:
            A :obj:`list`:. The list contains items that are dicts should be liked {"label": "XXX", "score": 0.82}
                It is preferred if the returned list is in decreasing `score` order
        """
        im = inputs.convert("RGB")
        inputs = self.transform(im).unsqueeze(0)

        with torch.no_grad():
            out = self.model(inputs)

        probabilities = out.squeeze(0).softmax(dim=0)
        values, indices = torch.topk(probabilities, self.top_k)

        labels = [
            {
                "label": self.dataset_info.index_to_description(i, detailed=True),
                "score": v.item(),
            }
            for i, v in zip(indices, values)
        ]
        return labels