diff --git a/brainscore_vision/models/regnet/__init__.py b/brainscore_vision/models/regnet/__init__.py new file mode 100644 index 000000000..0c95e6360 --- /dev/null +++ b/brainscore_vision/models/regnet/__init__.py @@ -0,0 +1,14 @@ +from brainscore_vision import model_registry +from brainscore_vision.model_helpers.brain_transformation import ModelCommitment +from .model import get_model, LAYERS + +BIBTEX = """@inproceedings{radosavovic2020designing, + title={Designing network design spaces}, + author={Radosavovic, Ilija and Kosaraju, Raj Prateek and Girshick, Ross and He, Kaiming and Doll{\'a}r, Piotr}, + booktitle={Proceedings of the IEEE/CVF conference on computer vision and pattern recognition}, + pages={10428--10436}, + year={2020} +}""" + +model_registry['regnet_y_400mf'] = lambda: ModelCommitment( + identifier='regnet_y_400mf', activations_model=get_model(), layers=LAYERS) diff --git a/brainscore_vision/models/regnet/model.py b/brainscore_vision/models/regnet/model.py new file mode 100644 index 000000000..4690dbcbd --- /dev/null +++ b/brainscore_vision/models/regnet/model.py @@ -0,0 +1,17 @@ +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 + +# these layer choices were not investigated in any depth, we blindly picked all high-level blocks +LAYERS = ['trunk_output.block1', 'trunk_output.block2', 'trunk_output.block3', 'trunk_output.block4'] + + +def get_model(): + model = torchvision.models.regnet_y_400mf(pretrained=True) + preprocessing = functools.partial(load_preprocess_images, image_size=224) + wrapper = PytorchWrapper(identifier='regnet_y_400mf', model=model, preprocessing=preprocessing) + wrapper.image_size = 224 + return wrapper diff --git a/brainscore_vision/models/regnet/test.py b/brainscore_vision/models/regnet/test.py new file mode 100644 index 000000000..ad9c5b3bf --- /dev/null +++ b/brainscore_vision/models/regnet/test.py @@ -0,0 +1,17 @@ +import logging +import sys + +import pytest +from pytest import approx + +from brainscore_vision import score + +logging.basicConfig(stream=sys.stdout, level=logging.DEBUG) + + +@pytest.mark.travis_slow +@pytest.mark.memory_intense +def test_score(): + actual_score = score(model_identifier="regnet_y_400mf", benchmark_identifier="MajajHong2015public.IT-pls", + conda_active=True) + assert actual_score == approx(0.532, abs=0.0005)