Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

brain-score.org (user:484) | Add new plugin(s): models: [regnet] #489

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions brainscore_vision/models/regnet/__init__.py
Original file line number Diff line number Diff line change
@@ -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)
17 changes: 17 additions & 0 deletions brainscore_vision/models/regnet/model.py
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions brainscore_vision/models/regnet/test.py
Original file line number Diff line number Diff line change
@@ -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)