Skip to content

Commit

Permalink
add sam_test_resnet_4 to models (#1313)
Browse files Browse the repository at this point in the history
Co-authored-by: Jenkins <[email protected]>
  • Loading branch information
kvfairchild and Jenkins authored Oct 9, 2024
1 parent 49365b1 commit 97b6e34
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
5 changes: 5 additions & 0 deletions brainscore_vision/models/sam_test_resnet_4/__init__.py
Original file line number Diff line number Diff line change
@@ -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['sam_test_resnet_4'] = lambda: ModelCommitment(identifier='sam_test_resnet_4', activations_model=get_model('sam_test_resnet_4'), layers=get_layers('sam_test_resnet_4'))
26 changes: 26 additions & 0 deletions brainscore_vision/models/sam_test_resnet_4/model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
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

def get_model(name):
assert name == 'sam_test_resnet_4'
model = torchvision.models.resnet50(pretrained=True)
preprocessing = functools.partial(load_preprocess_images, image_size=224)
wrapper = PytorchWrapper(identifier='sam_test_resnet', model=model, preprocessing=preprocessing)
wrapper.image_size = 224
return wrapper


def get_layers(name):
assert name == 'sam_test_resnet_4'
return ['conv1','layer1', 'layer2', 'layer3', 'layer4', 'fc']


def get_bibtex(model_identifier):
return """"""


if __name__ == '__main__':
check_models.check_base_models(__name__)
2 changes: 2 additions & 0 deletions brainscore_vision/models/sam_test_resnet_4/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
torchvision
torch
8 changes: 8 additions & 0 deletions brainscore_vision/models/sam_test_resnet_4/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import pytest
import brainscore_vision


@pytest.mark.travis_slow
def test_has_identifier():
model = brainscore_vision.load_model('sam_test_resnet_4')
assert model.identifier == 'sam_test_resnet_4'

0 comments on commit 97b6e34

Please sign in to comment.