brain-score / vision

A framework for evaluating models on their alignment to brain and behavioral measurements (50+ benchmarks)
http://brain-score.org
MIT License
120 stars 74 forks source link

model `vit` requires package `transformers` but has no `requirements.txt` #682

Closed benlonnqvist closed 5 months ago

benlonnqvist commented 5 months ago

515 introduced the model vit which requires the transformers package, but transformers is not included in the brain-score/vision pyproject.toml nor the models/vit/requirements.txt file. If the requirement exists somewhere else and I missed it, apologies!

mschrimpf commented 5 months ago

related: http://braintree.mit.edu:8080/job/unittest_plugins/928/console

brainscore_vision/model_helpers/generic_plugin_tests.py::test_identifier[vit-base-patch16-224-in21k_debug0118] FAILED [ 20%]
brainscore_vision/model_helpers/generic_plugin_tests.py::test_visual_degrees[vit-base-patch16-224-in21k_debug0118] FAILED [ 40%]
brainscore_vision/model_helpers/generic_plugin_tests.py::test_start_task_or_recording[vit-base-patch16-224-in21k_debug0118] FAILED [ 60%]
brainscore_vision/model_helpers/generic_plugin_tests.py::test_look_at_behavior_probabilities[vit-base-patch16-224-in21k_debug0118] FAILED [ 80%]
brainscore_vision/model_helpers/generic_plugin_tests.py::test_look_at_neural_V1[vit-base-patch16-224-in21k_debug0118] FAILED [100%]

...

logger = <Logger brainscore_vision.models.vit.model.PytorchWrapperV2 (INFO)>

    def __init__(self, model, preprocessing, identifier=None, forward_kwargs=None, *args, **kwargs):
        import torch
        logger = logging.getLogger(fullname(self))
        self._device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
        logger.debug(f"Using device {self._device}")
        self._model = model
>       self._model = self._model.to(self._device)
E       AttributeError: 'str' object has no attribute 'to'

brainscore_vision/model_helpers/activations/pytorch.py:20: AttributeError
mschrimpf commented 5 months ago

The issue is that the PytorchWrapperV2 defined in the vit plugin passes arguments positionally to the super-class: https://github.com/brain-score/vision/blob/master/brainscore_vision/models/vit/model.py#L67-L69 which expects the model and not the identifier first: https://github.com/brain-score/vision/blob/master/brainscore_vision/models/vit/model.py#L67-L69

mschrimpf commented 5 months ago

to actually answer the original question: the transformers dependency is specified here https://github.com/brain-score/vision/blob/master/brainscore_vision/models/vit/setup.py#L9

samwinebrake commented 5 months ago

@benlonnqvist reverting PR 515 now. let me know if you need help resubmitting!