diff --git a/brainscore_vision/models/convnext_base_fb_in1k/__init__.py b/brainscore_vision/models/convnext_base_fb_in1k/__init__.py new file mode 100644 index 000000000..f938c7d8f --- /dev/null +++ b/brainscore_vision/models/convnext_base_fb_in1k/__init__.py @@ -0,0 +1,5 @@ +from brainscore_vision import model_registry +from brainscore_vision.model_helpers.brain_transformation import ModelCommitment +from .model import get_model, get_layers + +model_registry['convnext_base_fb_in1k'] = lambda: ModelCommitment(identifier='convnext_base_fb_in1k', activations_model=get_model('convnext_base_fb_in1k'), layers=get_layers('convnext_base_fb_in1k')) \ No newline at end of file diff --git a/brainscore_vision/models/convnext_base_fb_in1k/model.py b/brainscore_vision/models/convnext_base_fb_in1k/model.py new file mode 100644 index 000000000..e4848eb4f --- /dev/null +++ b/brainscore_vision/models/convnext_base_fb_in1k/model.py @@ -0,0 +1,39 @@ + +from brainscore_vision.model_helpers.check_submission import check_models +import functools +import torchvision.models +from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper +from brainscore_vision.model_helpers.activations.pytorch import load_preprocess_images +import timm + +# This is an example implementation for submitting resnet-50 as a pytorch model + +# Attention: It is important, that the wrapper identifier is unique per model! +# The results will otherwise be the same due to brain-scores internal result caching mechanism. +# Please load your pytorch model for usage in CPU. There won't be GPUs available for scoring your model. +# If the model requires a GPU, contact the brain-score team directly. + + +def get_model(name): + assert name == 'convnext_base_fb_in1k' + + model = timm.create_model('convnext_base.fb_in1k',pretrained=True) + #,# features_only=True, + preprocessing = functools.partial(load_preprocess_images, image_size=224) + wrapper = PytorchWrapper(identifier='convnext_base_fb_in1k', model=model, preprocessing=preprocessing) + wrapper.image_size = 224 + return wrapper + + +def get_layers(name): + assert name == 'convnext_base_fb_in1k' + return ['stem', 'stages.0', 'stages.1', 'stages.2', 'stages.3', 'head'] + + +def get_bibtex(model_identifier): + return """""" + + +if __name__ == '__main__': + check_models.check_base_models(__name__) + diff --git a/brainscore_vision/models/convnext_base_fb_in1k/region_layer_map/convnext_base_fb_in1k.json b/brainscore_vision/models/convnext_base_fb_in1k/region_layer_map/convnext_base_fb_in1k.json new file mode 100644 index 000000000..df96cfe8b --- /dev/null +++ b/brainscore_vision/models/convnext_base_fb_in1k/region_layer_map/convnext_base_fb_in1k.json @@ -0,0 +1,6 @@ +{ + "V1": "stages.3", + "V2": "stages.0", + "V4": "stages.0", + "IT": "stages.3" +} \ No newline at end of file diff --git a/brainscore_vision/models/convnext_base_fb_in1k/requirements.txt b/brainscore_vision/models/convnext_base_fb_in1k/requirements.txt new file mode 100644 index 000000000..2deaa4e14 --- /dev/null +++ b/brainscore_vision/models/convnext_base_fb_in1k/requirements.txt @@ -0,0 +1,3 @@ +torch +torchvision +timm \ No newline at end of file diff --git a/brainscore_vision/models/convnext_base_fb_in1k/test.py b/brainscore_vision/models/convnext_base_fb_in1k/test.py new file mode 100644 index 000000000..75e52e065 --- /dev/null +++ b/brainscore_vision/models/convnext_base_fb_in1k/test.py @@ -0,0 +1,8 @@ +import pytest +import brainscore_vision + + +@pytest.mark.travis_slow +def test_has_identifier(): + model = brainscore_vision.load_model('convnext_base_fb_in1k') + assert model.identifier == 'convnext_base_fb_in1k' \ No newline at end of file