-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add sam_test_resnet_4 to models (#1313)
Co-authored-by: Jenkins <[email protected]>
- Loading branch information
1 parent
49365b1
commit 97b6e34
Showing
4 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
torchvision | ||
torch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |