Skip to content

Commit

Permalink
add dbp_resnet50_julios to models (#531)
Browse files Browse the repository at this point in the history
Co-authored-by: AutoJenkins <[email protected]>
Co-authored-by: Khaled K Shehada <[email protected]>
  • Loading branch information
3 people authored Feb 26, 2024
1 parent 201482b commit 7f4f56b
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 0 deletions.
5 changes: 5 additions & 0 deletions brainscore_vision/models/dbp_resnet50_julios/__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['dbp_resnet50_julios'] = lambda: ModelCommitment(identifier='dbp_resnet50_julios', activations_model=get_model('dbp_resnet50_julios'), layers=get_layers('dbp_resnet50_julios'))
Binary file not shown.
53 changes: 53 additions & 0 deletions brainscore_vision/models/dbp_resnet50_julios/model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
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 ['dbp_resnet50_julios']


def get_model(name):
assert name == 'dbp_resnet50_julios'
model = torch.load('brainscore_vision/models/dbp_resnet50_julios/dbp_export.pt')
# download_weights(
# bucket='brainscore-vision',
# folder_path='models/resnet50-deepdive-2',
# filename_version_sha=[('ckpt.pth', 'C722T4BityNPpazdXWiAeu8pGBxKIudb', '0186929df5d04451995d94cd332a3603a00594fe')],
# save_directory=Path(__file__).parent)
# ckpt_path = os.path.join(os.path.dirname(__file__), 'ckpt.pth')
# state_dict = torch.load(ckpt_path, map_location=torch.device('cpu'))
# model.load_state_dict(state_dict)

preprocessing = functools.partial(load_preprocess_images, image_size=224)
print(preprocessing)
wrapper = PytorchWrapper(identifier='dbp_resnet50_julios', model=model, preprocessing=preprocessing)
wrapper.image_size = 224
return wrapper


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


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


if __name__ == '__main__':
check_models.check_base_models(__name__)
25 changes: 25 additions & 0 deletions brainscore_vision/models/dbp_resnet50_julios/setup.py
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',
)
1 change: 1 addition & 0 deletions brainscore_vision/models/dbp_resnet50_julios/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Left empty as part of 2023 models migration

0 comments on commit 7f4f56b

Please sign in to comment.