Skip to content

Can I use a pretrained model that returns scores inside a dict rather than directly? #1343

Discussion options

You must be logged in to vote

Hi @NishantTharani Thank you very much for using ART!

No, the interfaces are only supporting arrays and tensors. I think a simple solution for you could be to wrap the model into a new model forwarding logits as tensor, e.g.:
(Code example, not tested)

class ModelWrapper(nn.Module):
    def __init__(self, model: torch.nn.Module):
    super().__init__()
    self._model = model

    def forward(self, x):
        result = self._model(x)
        return result["logits"]

and provide an instance of ModelWrapper to ART's tools.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@NishantTharani
Comment options

Answer selected by NishantTharani
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants