-
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.
- Loading branch information
AutoJenkins
committed
Aug 29, 2024
1 parent
3c27e4a
commit 9b1bea5
Showing
4 changed files
with
77 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,7 @@ | ||
from brainscore_vision import model_registry | ||
from brainscore_vision.model_helpers.brain_transformation import ModelCommitment | ||
from .model import get_model, get_layers | ||
|
||
model_registry['alexnet_7be5be79'] = lambda: ModelCommitment(identifier='alexnet_7be5be79', | ||
activations_model=get_model('alexnet_7be5be79'), | ||
layers=get_layers('alexnet_7be5be79')) |
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,44 @@ | ||
from brainscore_vision.model_helpers.check_submission import check_models | ||
import functools | ||
import os | ||
import torchvision.models | ||
from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper | ||
from brainscore_vision.model_helpers.activations.pytorch import load_preprocess_images | ||
from pathlib import Path | ||
from brainscore_vision.model_helpers import download_weights | ||
import torch | ||
|
||
# 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. | ||
from brainscore_vision.model_helpers.check_submission import check_models | ||
|
||
|
||
def get_model_list(): | ||
return ['alexnet_7be5be79'] | ||
|
||
|
||
def get_model(name): | ||
assert name == 'alexnet_7be5be79' | ||
model = torchvision.models.alexnet(pretrained=True) | ||
preprocessing = functools.partial(load_preprocess_images, image_size=224) | ||
wrapper = PytorchWrapper(identifier='alexnet_7be5be79', model=model, preprocessing=preprocessing) | ||
wrapper.image_size = 224 | ||
return wrapper | ||
|
||
|
||
def get_layers(name): | ||
assert name == 'alexnet_7be5be79' | ||
return ['features.0','features.3', 'features.6', 'features.8', 'features.10', 'classifier.1', | ||
'classifier.4', 'classifier.6'] | ||
|
||
|
||
def get_bibtex(model_identifier): | ||
return """xx""" | ||
|
||
|
||
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,25 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
from setuptools import setup, find_packages | ||
|
||
requirements = [ "torchvision", | ||
"torch" | ||
] | ||
|
||
setup( | ||
packages=find_packages(exclude=['tests']), | ||
include_package_data=True, | ||
install_requires=requirements, | ||
license="MIT license", | ||
zip_safe=False, | ||
keywords='brain-score template', | ||
classifiers=[ | ||
'Development Status :: 2 - Pre-Alpha', | ||
'Intended Audience :: Developers', | ||
'License :: OSI Approved :: MIT License', | ||
'Natural Language :: English', | ||
'Programming Language :: Python :: 3.7', | ||
], | ||
test_suite='tests', | ||
) |
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 @@ | ||
# Left empty as part of 2023 models migration |