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 submission (user:237) | (public:False) #767

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions brainscore_vision/models/EVA-02/__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['EVA-02'] = lambda: ModelCommitment(identifier='EVA-02', activations_model=get_model('EVA-02'), layers=get_layers('EVA-02'))
53 changes: 53 additions & 0 deletions brainscore_vision/models/EVA-02/model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import timm
from brainscore_vision.model_helpers.check_submission import check_models
import functools
from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper
from brainscore_vision.model_helpers.activations.pytorch import load_preprocess_images
import torch
import numpy as np
from brainscore_vision.model_helpers.brain_transformation import ModelCommitment


# This is an example implementation for submitting custom model named my_custom_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.



def get_model_list():
return ['EVA-02']


def get_model(name):
assert name == 'EVA-02'
preprocessing = functools.partial(load_preprocess_images, image_size=224)

# model = ModelCommitment(identifier='EVA-02', activations_model=activations_model,
# # specify layers to consider
# # layers=['conv1', 'relu1', 'relu2'])

model = timm.create_model('eva02_large_patch14_448.mim_m38m_ft_in22k_in1k', pretrained=True)

activations_model = PytorchWrapper(identifier='EVA-02', model=model, preprocessing=preprocessing)

wrapper = PytorchWrapper(identifier='EVA-02', model=model, preprocessing=preprocessing)
wrapper.image_size = 224
return wrapper


def get_layers(name):
assert name == 'EVA-02'
return ['model.blocks[0].mlp', 'model.blocks[3].mlp', 'model.blocks[6].mlp',
'model.blocks[9].mlp', 'model.blocks[12].mlp', 'model.blocks[15].mlp',
'model.blocks[18].mlp', 'model.blocks[21].mlp', 'model.blocks[23].mlp']


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


if __name__ == '__main__':
check_models.check_base_models(__name__)
26 changes: 26 additions & 0 deletions brainscore_vision/models/EVA-02/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from setuptools import setup, find_packages

requirements = [ "torchvision",
"torch",
"timm"
]

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',
)
1 change: 1 addition & 0 deletions brainscore_vision/models/EVA-02/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Left empty as part of 2023 models migration