From 3d8fdc9dc166146a2e174e7516094a5bfa21b7c3 Mon Sep 17 00:00:00 2001 From: Jenkins Date: Fri, 6 Dec 2024 09:44:57 -0500 Subject: [PATCH] add alexnet_ambient_4 to models --- .../models/alexnet_ambient_4/__init__.py | 6 + .../models/alexnet_ambient_4/config.json | 32 + .../models/alexnet_ambient_4/config.txt | 900 ++++++++++++++++++ .../models/alexnet_ambient_4/model.py | 74 ++ .../models/alexnet_ambient_4/setup.py | 29 + .../models/alexnet_ambient_4/test.py | 1 + 6 files changed, 1042 insertions(+) create mode 100644 brainscore_vision/models/alexnet_ambient_4/__init__.py create mode 100644 brainscore_vision/models/alexnet_ambient_4/config.json create mode 100644 brainscore_vision/models/alexnet_ambient_4/config.txt create mode 100644 brainscore_vision/models/alexnet_ambient_4/model.py create mode 100644 brainscore_vision/models/alexnet_ambient_4/setup.py create mode 100644 brainscore_vision/models/alexnet_ambient_4/test.py diff --git a/brainscore_vision/models/alexnet_ambient_4/__init__.py b/brainscore_vision/models/alexnet_ambient_4/__init__.py new file mode 100644 index 000000000..c9714434f --- /dev/null +++ b/brainscore_vision/models/alexnet_ambient_4/__init__.py @@ -0,0 +1,6 @@ + +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_ambient_iteration=4'] = lambda: ModelCommitment(identifier='alexnet_ambient_iteration=4', activations_model=get_model(f'alexnet', f'ambient', f'4'), layers=get_layers(f'alexnet',f'ambient', f'4')) + \ No newline at end of file diff --git a/brainscore_vision/models/alexnet_ambient_4/config.json b/brainscore_vision/models/alexnet_ambient_4/config.json new file mode 100644 index 000000000..d393e66d8 --- /dev/null +++ b/brainscore_vision/models/alexnet_ambient_4/config.json @@ -0,0 +1,32 @@ +{ + "alexnet_ambient_4": { + "model_name": "alexnet", + "keyword": "ambient", + "model_id": "alexnet_ambient_iteration=4", + "resize_size": 256, + "crop_size": 224, + "checkpoint_url": "https://eggerbernhard.ch/latest_alexnet/ambient_4.ckpt", + "model_commitment": { + "layers": [ + "conv1", + "bn1", + "relu", + "maxpool", + "layer1", + "layer1.0", + "layer1.0.conv1", + "layer1.0.bn1", + "layer1.0.relu", + "layer1.0.conv2", + "layer1.0.bn2", + "layer1.0.relu_2", + "layer1.0.conv3", + "layer1.0.bn3", + "layer1.0.shortcut", + "layer1.0.shortcut.conv1", + "layer1.0.shortcut.bn1", + "fc" + ] + } + } +} \ No newline at end of file diff --git a/brainscore_vision/models/alexnet_ambient_4/config.txt b/brainscore_vision/models/alexnet_ambient_4/config.txt new file mode 100644 index 000000000..c02909afa --- /dev/null +++ b/brainscore_vision/models/alexnet_ambient_4/config.txt @@ -0,0 +1,900 @@ +{ + "alexnet_less_variation_1": { + "model_name": "alexnet", + "keyword": "less_variation", + "model_id": "alexnet_less_variation_iteration=1", + "resize_size": 256, + "crop_size": 224, + "checkpoint_url": "https://eggerbernhard.ch/latest_alexnet/less_variation_1.ckpt", + "model_commitment": { + "layers": [ + "conv1", + "bn1", + "relu", + "maxpool", + "layer1", + "layer1.0", + "layer1.0.conv1", + "layer1.0.bn1", + "layer1.0.relu", + "layer1.0.conv2", + "layer1.0.bn2", + "layer1.0.relu_2", + "layer1.0.conv3", + "layer1.0.bn3", + "layer1.0.shortcut", + "layer1.0.shortcut.conv1", + "layer1.0.shortcut.bn1", + "fc" + ] + } + } +}{ + "alexnet_less_variation_2": { + "model_name": "alexnet", + "keyword": "less_variation", + "model_id": "alexnet_less_variation_iteration=2", + "resize_size": 256, + "crop_size": 224, + "checkpoint_url": "https://eggerbernhard.ch/latest_alexnet/less_variation_2.ckpt", + "model_commitment": { + "layers": [ + "conv1", + "bn1", + "relu", + "maxpool", + "layer1", + "layer1.0", + "layer1.0.conv1", + "layer1.0.bn1", + "layer1.0.relu", + "layer1.0.conv2", + "layer1.0.bn2", + "layer1.0.relu_2", + "layer1.0.conv3", + "layer1.0.bn3", + "layer1.0.shortcut", + "layer1.0.shortcut.conv1", + "layer1.0.shortcut.bn1", + "fc" + ] + } + } +}{ + "alexnet_less_variation_3": { + "model_name": "alexnet", + "keyword": "less_variation", + "model_id": "alexnet_less_variation_iteration=3", + "resize_size": 256, + "crop_size": 224, + "checkpoint_url": "https://eggerbernhard.ch/latest_alexnet/less_variation_3.ckpt", + "model_commitment": { + "layers": [ + "conv1", + "bn1", + "relu", + "maxpool", + "layer1", + "layer1.0", + "layer1.0.conv1", + "layer1.0.bn1", + "layer1.0.relu", + "layer1.0.conv2", + "layer1.0.bn2", + "layer1.0.relu_2", + "layer1.0.conv3", + "layer1.0.bn3", + "layer1.0.shortcut", + "layer1.0.shortcut.conv1", + "layer1.0.shortcut.bn1", + "fc" + ] + } + } +}{ + "alexnet_less_variation_4": { + "model_name": "alexnet", + "keyword": "less_variation", + "model_id": "alexnet_less_variation_iteration=4", + "resize_size": 256, + "crop_size": 224, + "checkpoint_url": "https://eggerbernhard.ch/latest_alexnet/less_variation_4.ckpt", + "model_commitment": { + "layers": [ + "conv1", + "bn1", + "relu", + "maxpool", + "layer1", + "layer1.0", + "layer1.0.conv1", + "layer1.0.bn1", + "layer1.0.relu", + "layer1.0.conv2", + "layer1.0.bn2", + "layer1.0.relu_2", + "layer1.0.conv3", + "layer1.0.bn3", + "layer1.0.shortcut", + "layer1.0.shortcut.conv1", + "layer1.0.shortcut.bn1", + "fc" + ] + } + } +}{ + "alexnet_less_variation_5": { + "model_name": "alexnet", + "keyword": "less_variation", + "model_id": "alexnet_less_variation_iteration=5", + "resize_size": 256, + "crop_size": 224, + "checkpoint_url": "https://eggerbernhard.ch/latest_alexnet/less_variation_5.ckpt", + "model_commitment": { + "layers": [ + "conv1", + "bn1", + "relu", + "maxpool", + "layer1", + "layer1.0", + "layer1.0.conv1", + "layer1.0.bn1", + "layer1.0.relu", + "layer1.0.conv2", + "layer1.0.bn2", + "layer1.0.relu_2", + "layer1.0.conv3", + "layer1.0.bn3", + "layer1.0.shortcut", + "layer1.0.shortcut.conv1", + "layer1.0.shortcut.bn1", + "fc" + ] + } + } +}{ + "alexnet_no_variation_1": { + "model_name": "alexnet", + "keyword": "no_variation", + "model_id": "alexnet_no_variation_iteration=1", + "resize_size": 256, + "crop_size": 224, + "checkpoint_url": "https://eggerbernhard.ch/latest_alexnet/no_variation_1.ckpt", + "model_commitment": { + "layers": [ + "conv1", + "bn1", + "relu", + "maxpool", + "layer1", + "layer1.0", + "layer1.0.conv1", + "layer1.0.bn1", + "layer1.0.relu", + "layer1.0.conv2", + "layer1.0.bn2", + "layer1.0.relu_2", + "layer1.0.conv3", + "layer1.0.bn3", + "layer1.0.shortcut", + "layer1.0.shortcut.conv1", + "layer1.0.shortcut.bn1", + "fc" + ] + } + } +}{ + "alexnet_no_variation_2": { + "model_name": "alexnet", + "keyword": "no_variation", + "model_id": "alexnet_no_variation_iteration=2", + "resize_size": 256, + "crop_size": 224, + "checkpoint_url": "https://eggerbernhard.ch/latest_alexnet/no_variation_2.ckpt", + "model_commitment": { + "layers": [ + "conv1", + "bn1", + "relu", + "maxpool", + "layer1", + "layer1.0", + "layer1.0.conv1", + "layer1.0.bn1", + "layer1.0.relu", + "layer1.0.conv2", + "layer1.0.bn2", + "layer1.0.relu_2", + "layer1.0.conv3", + "layer1.0.bn3", + "layer1.0.shortcut", + "layer1.0.shortcut.conv1", + "layer1.0.shortcut.bn1", + "fc" + ] + } + } +}{ + "alexnet_no_variation_3": { + "model_name": "alexnet", + "keyword": "no_variation", + "model_id": "alexnet_no_variation_iteration=3", + "resize_size": 256, + "crop_size": 224, + "checkpoint_url": "https://eggerbernhard.ch/latest_alexnet/no_variation_3.ckpt", + "model_commitment": { + "layers": [ + "conv1", + "bn1", + "relu", + "maxpool", + "layer1", + "layer1.0", + "layer1.0.conv1", + "layer1.0.bn1", + "layer1.0.relu", + "layer1.0.conv2", + "layer1.0.bn2", + "layer1.0.relu_2", + "layer1.0.conv3", + "layer1.0.bn3", + "layer1.0.shortcut", + "layer1.0.shortcut.conv1", + "layer1.0.shortcut.bn1", + "fc" + ] + } + } +}{ + "alexnet_no_variation_4": { + "model_name": "alexnet", + "keyword": "no_variation", + "model_id": "alexnet_no_variation_iteration=4", + "resize_size": 256, + "crop_size": 224, + "checkpoint_url": "https://eggerbernhard.ch/latest_alexnet/no_variation_4.ckpt", + "model_commitment": { + "layers": [ + "conv1", + "bn1", + "relu", + "maxpool", + "layer1", + "layer1.0", + "layer1.0.conv1", + "layer1.0.bn1", + "layer1.0.relu", + "layer1.0.conv2", + "layer1.0.bn2", + "layer1.0.relu_2", + "layer1.0.conv3", + "layer1.0.bn3", + "layer1.0.shortcut", + "layer1.0.shortcut.conv1", + "layer1.0.shortcut.bn1", + "fc" + ] + } + } +}{ + "alexnet_no_variation_5": { + "model_name": "alexnet", + "keyword": "no_variation", + "model_id": "alexnet_no_variation_iteration=5", + "resize_size": 256, + "crop_size": 224, + "checkpoint_url": "https://eggerbernhard.ch/latest_alexnet/no_variation_5.ckpt", + "model_commitment": { + "layers": [ + "conv1", + "bn1", + "relu", + "maxpool", + "layer1", + "layer1.0", + "layer1.0.conv1", + "layer1.0.bn1", + "layer1.0.relu", + "layer1.0.conv2", + "layer1.0.bn2", + "layer1.0.relu_2", + "layer1.0.conv3", + "layer1.0.bn3", + "layer1.0.shortcut", + "layer1.0.shortcut.conv1", + "layer1.0.shortcut.bn1", + "fc" + ] + } + } +}{ + "alexnet_z_axis_1": { + "model_name": "alexnet", + "keyword": "z_axis", + "model_id": "alexnet_z_axis_iteration=1", + "resize_size": 256, + "crop_size": 224, + "checkpoint_url": "https://eggerbernhard.ch/latest_alexnet/z_axis_1.ckpt", + "model_commitment": { + "layers": [ + "conv1", + "bn1", + "relu", + "maxpool", + "layer1", + "layer1.0", + "layer1.0.conv1", + "layer1.0.bn1", + "layer1.0.relu", + "layer1.0.conv2", + "layer1.0.bn2", + "layer1.0.relu_2", + "layer1.0.conv3", + "layer1.0.bn3", + "layer1.0.shortcut", + "layer1.0.shortcut.conv1", + "layer1.0.shortcut.bn1", + "fc" + ] + } + } +}{ + "alexnet_z_axis_2": { + "model_name": "alexnet", + "keyword": "z_axis", + "model_id": "alexnet_z_axis_iteration=2", + "resize_size": 256, + "crop_size": 224, + "checkpoint_url": "https://eggerbernhard.ch/latest_alexnet/z_axis_2.ckpt", + "model_commitment": { + "layers": [ + "conv1", + "bn1", + "relu", + "maxpool", + "layer1", + "layer1.0", + "layer1.0.conv1", + "layer1.0.bn1", + "layer1.0.relu", + "layer1.0.conv2", + "layer1.0.bn2", + "layer1.0.relu_2", + "layer1.0.conv3", + "layer1.0.bn3", + "layer1.0.shortcut", + "layer1.0.shortcut.conv1", + "layer1.0.shortcut.bn1", + "fc" + ] + } + } +}{ + "alexnet_z_axis_3": { + "model_name": "alexnet", + "keyword": "z_axis", + "model_id": "alexnet_z_axis_iteration=3", + "resize_size": 256, + "crop_size": 224, + "checkpoint_url": "https://eggerbernhard.ch/latest_alexnet/z_axis_3.ckpt", + "model_commitment": { + "layers": [ + "conv1", + "bn1", + "relu", + "maxpool", + "layer1", + "layer1.0", + "layer1.0.conv1", + "layer1.0.bn1", + "layer1.0.relu", + "layer1.0.conv2", + "layer1.0.bn2", + "layer1.0.relu_2", + "layer1.0.conv3", + "layer1.0.bn3", + "layer1.0.shortcut", + "layer1.0.shortcut.conv1", + "layer1.0.shortcut.bn1", + "fc" + ] + } + } +}{ + "alexnet_z_axis_4": { + "model_name": "alexnet", + "keyword": "z_axis", + "model_id": "alexnet_z_axis_iteration=4", + "resize_size": 256, + "crop_size": 224, + "checkpoint_url": "https://eggerbernhard.ch/latest_alexnet/z_axis_4.ckpt", + "model_commitment": { + "layers": [ + "conv1", + "bn1", + "relu", + "maxpool", + "layer1", + "layer1.0", + "layer1.0.conv1", + "layer1.0.bn1", + "layer1.0.relu", + "layer1.0.conv2", + "layer1.0.bn2", + "layer1.0.relu_2", + "layer1.0.conv3", + "layer1.0.bn3", + "layer1.0.shortcut", + "layer1.0.shortcut.conv1", + "layer1.0.shortcut.bn1", + "fc" + ] + } + } +}{ + "alexnet_z_axis_5": { + "model_name": "alexnet", + "keyword": "z_axis", + "model_id": "alexnet_z_axis_iteration=5", + "resize_size": 256, + "crop_size": 224, + "checkpoint_url": "https://eggerbernhard.ch/latest_alexnet/z_axis_5.ckpt", + "model_commitment": { + "layers": [ + "conv1", + "bn1", + "relu", + "maxpool", + "layer1", + "layer1.0", + "layer1.0.conv1", + "layer1.0.bn1", + "layer1.0.relu", + "layer1.0.conv2", + "layer1.0.bn2", + "layer1.0.relu_2", + "layer1.0.conv3", + "layer1.0.bn3", + "layer1.0.shortcut", + "layer1.0.shortcut.conv1", + "layer1.0.shortcut.bn1", + "fc" + ] + } + } +}{ + "alexnet_wo_shading_1": { + "model_name": "alexnet", + "keyword": "wo_shading", + "model_id": "alexnet_wo_shading_iteration=1", + "resize_size": 256, + "crop_size": 224, + "checkpoint_url": "https://eggerbernhard.ch/latest_alexnet/wo_shading_1.ckpt", + "model_commitment": { + "layers": [ + "conv1", + "bn1", + "relu", + "maxpool", + "layer1", + "layer1.0", + "layer1.0.conv1", + "layer1.0.bn1", + "layer1.0.relu", + "layer1.0.conv2", + "layer1.0.bn2", + "layer1.0.relu_2", + "layer1.0.conv3", + "layer1.0.bn3", + "layer1.0.shortcut", + "layer1.0.shortcut.conv1", + "layer1.0.shortcut.bn1", + "fc" + ] + } + } +}{ + "alexnet_wo_shading_2": { + "model_name": "alexnet", + "keyword": "wo_shading", + "model_id": "alexnet_wo_shading_iteration=2", + "resize_size": 256, + "crop_size": 224, + "checkpoint_url": "https://eggerbernhard.ch/latest_alexnet/wo_shading_2.ckpt", + "model_commitment": { + "layers": [ + "conv1", + "bn1", + "relu", + "maxpool", + "layer1", + "layer1.0", + "layer1.0.conv1", + "layer1.0.bn1", + "layer1.0.relu", + "layer1.0.conv2", + "layer1.0.bn2", + "layer1.0.relu_2", + "layer1.0.conv3", + "layer1.0.bn3", + "layer1.0.shortcut", + "layer1.0.shortcut.conv1", + "layer1.0.shortcut.bn1", + "fc" + ] + } + } +}{ + "alexnet_wo_shading_3": { + "model_name": "alexnet", + "keyword": "wo_shading", + "model_id": "alexnet_wo_shading_iteration=3", + "resize_size": 256, + "crop_size": 224, + "checkpoint_url": "https://eggerbernhard.ch/latest_alexnet/wo_shading_3.ckpt", + "model_commitment": { + "layers": [ + "conv1", + "bn1", + "relu", + "maxpool", + "layer1", + "layer1.0", + "layer1.0.conv1", + "layer1.0.bn1", + "layer1.0.relu", + "layer1.0.conv2", + "layer1.0.bn2", + "layer1.0.relu_2", + "layer1.0.conv3", + "layer1.0.bn3", + "layer1.0.shortcut", + "layer1.0.shortcut.conv1", + "layer1.0.shortcut.bn1", + "fc" + ] + } + } +}{ + "alexnet_wo_shading_4": { + "model_name": "alexnet", + "keyword": "wo_shading", + "model_id": "alexnet_wo_shading_iteration=4", + "resize_size": 256, + "crop_size": 224, + "checkpoint_url": "https://eggerbernhard.ch/latest_alexnet/wo_shading_4.ckpt", + "model_commitment": { + "layers": [ + "conv1", + "bn1", + "relu", + "maxpool", + "layer1", + "layer1.0", + "layer1.0.conv1", + "layer1.0.bn1", + "layer1.0.relu", + "layer1.0.conv2", + "layer1.0.bn2", + "layer1.0.relu_2", + "layer1.0.conv3", + "layer1.0.bn3", + "layer1.0.shortcut", + "layer1.0.shortcut.conv1", + "layer1.0.shortcut.bn1", + "fc" + ] + } + } +}{ + "alexnet_wo_shading_5": { + "model_name": "alexnet", + "keyword": "wo_shading", + "model_id": "alexnet_wo_shading_iteration=5", + "resize_size": 256, + "crop_size": 224, + "checkpoint_url": "https://eggerbernhard.ch/latest_alexnet/wo_shading_5.ckpt", + "model_commitment": { + "layers": [ + "conv1", + "bn1", + "relu", + "maxpool", + "layer1", + "layer1.0", + "layer1.0.conv1", + "layer1.0.bn1", + "layer1.0.relu", + "layer1.0.conv2", + "layer1.0.bn2", + "layer1.0.relu_2", + "layer1.0.conv3", + "layer1.0.bn3", + "layer1.0.shortcut", + "layer1.0.shortcut.conv1", + "layer1.0.shortcut.bn1", + "fc" + ] + } + } +}{ + "alexnet_wo_shadows_1": { + "model_name": "alexnet", + "keyword": "wo_shadows", + "model_id": "alexnet_wo_shadows_iteration=1", + "resize_size": 256, + "crop_size": 224, + "checkpoint_url": "https://eggerbernhard.ch/latest_alexnet/wo_shadows_1.ckpt", + "model_commitment": { + "layers": [ + "conv1", + "bn1", + "relu", + "maxpool", + "layer1", + "layer1.0", + "layer1.0.conv1", + "layer1.0.bn1", + "layer1.0.relu", + "layer1.0.conv2", + "layer1.0.bn2", + "layer1.0.relu_2", + "layer1.0.conv3", + "layer1.0.bn3", + "layer1.0.shortcut", + "layer1.0.shortcut.conv1", + "layer1.0.shortcut.bn1", + "fc" + ] + } + } +}{ + "alexnet_wo_shadows_2": { + "model_name": "alexnet", + "keyword": "wo_shadows", + "model_id": "alexnet_wo_shadows_iteration=2", + "resize_size": 256, + "crop_size": 224, + "checkpoint_url": "https://eggerbernhard.ch/latest_alexnet/wo_shadows_2.ckpt", + "model_commitment": { + "layers": [ + "conv1", + "bn1", + "relu", + "maxpool", + "layer1", + "layer1.0", + "layer1.0.conv1", + "layer1.0.bn1", + "layer1.0.relu", + "layer1.0.conv2", + "layer1.0.bn2", + "layer1.0.relu_2", + "layer1.0.conv3", + "layer1.0.bn3", + "layer1.0.shortcut", + "layer1.0.shortcut.conv1", + "layer1.0.shortcut.bn1", + "fc" + ] + } + } +}{ + "alexnet_wo_shadows_3": { + "model_name": "alexnet", + "keyword": "wo_shadows", + "model_id": "alexnet_wo_shadows_iteration=3", + "resize_size": 256, + "crop_size": 224, + "checkpoint_url": "https://eggerbernhard.ch/latest_alexnet/wo_shadows_3.ckpt", + "model_commitment": { + "layers": [ + "conv1", + "bn1", + "relu", + "maxpool", + "layer1", + "layer1.0", + "layer1.0.conv1", + "layer1.0.bn1", + "layer1.0.relu", + "layer1.0.conv2", + "layer1.0.bn2", + "layer1.0.relu_2", + "layer1.0.conv3", + "layer1.0.bn3", + "layer1.0.shortcut", + "layer1.0.shortcut.conv1", + "layer1.0.shortcut.bn1", + "fc" + ] + } + } +}{ + "alexnet_wo_shadows_4": { + "model_name": "alexnet", + "keyword": "wo_shadows", + "model_id": "alexnet_wo_shadows_iteration=4", + "resize_size": 256, + "crop_size": 224, + "checkpoint_url": "https://eggerbernhard.ch/latest_alexnet/wo_shadows_4.ckpt", + "model_commitment": { + "layers": [ + "conv1", + "bn1", + "relu", + "maxpool", + "layer1", + "layer1.0", + "layer1.0.conv1", + "layer1.0.bn1", + "layer1.0.relu", + "layer1.0.conv2", + "layer1.0.bn2", + "layer1.0.relu_2", + "layer1.0.conv3", + "layer1.0.bn3", + "layer1.0.shortcut", + "layer1.0.shortcut.conv1", + "layer1.0.shortcut.bn1", + "fc" + ] + } + } +}{ + "alexnet_wo_shadows_5": { + "model_name": "alexnet", + "keyword": "wo_shadows", + "model_id": "alexnet_wo_shadows_iteration=5", + "resize_size": 256, + "crop_size": 224, + "checkpoint_url": "https://eggerbernhard.ch/latest_alexnet/wo_shadows_5.ckpt", + "model_commitment": { + "layers": [ + "conv1", + "bn1", + "relu", + "maxpool", + "layer1", + "layer1.0", + "layer1.0.conv1", + "layer1.0.bn1", + "layer1.0.relu", + "layer1.0.conv2", + "layer1.0.bn2", + "layer1.0.relu_2", + "layer1.0.conv3", + "layer1.0.bn3", + "layer1.0.shortcut", + "layer1.0.shortcut.conv1", + "layer1.0.shortcut.bn1", + "fc" + ] + } + } +}{ + "alexnet_ambient_1": { + "model_name": "alexnet", + "keyword": "ambient", + "model_id": "alexnet_ambient_iteration=1", + "resize_size": 256, + "crop_size": 224, + "checkpoint_url": "https://eggerbernhard.ch/latest_alexnet/ambient_1.ckpt", + "model_commitment": { + "layers": [ + "conv1", + "bn1", + "relu", + "maxpool", + "layer1", + "layer1.0", + "layer1.0.conv1", + "layer1.0.bn1", + "layer1.0.relu", + "layer1.0.conv2", + "layer1.0.bn2", + "layer1.0.relu_2", + "layer1.0.conv3", + "layer1.0.bn3", + "layer1.0.shortcut", + "layer1.0.shortcut.conv1", + "layer1.0.shortcut.bn1", + "fc" + ] + } + } +}{ + "alexnet_ambient_2": { + "model_name": "alexnet", + "keyword": "ambient", + "model_id": "alexnet_ambient_iteration=2", + "resize_size": 256, + "crop_size": 224, + "checkpoint_url": "https://eggerbernhard.ch/latest_alexnet/ambient_2.ckpt", + "model_commitment": { + "layers": [ + "conv1", + "bn1", + "relu", + "maxpool", + "layer1", + "layer1.0", + "layer1.0.conv1", + "layer1.0.bn1", + "layer1.0.relu", + "layer1.0.conv2", + "layer1.0.bn2", + "layer1.0.relu_2", + "layer1.0.conv3", + "layer1.0.bn3", + "layer1.0.shortcut", + "layer1.0.shortcut.conv1", + "layer1.0.shortcut.bn1", + "fc" + ] + } + } +}{ + "alexnet_ambient_3": { + "model_name": "alexnet", + "keyword": "ambient", + "model_id": "alexnet_ambient_iteration=3", + "resize_size": 256, + "crop_size": 224, + "checkpoint_url": "https://eggerbernhard.ch/latest_alexnet/ambient_3.ckpt", + "model_commitment": { + "layers": [ + "conv1", + "bn1", + "relu", + "maxpool", + "layer1", + "layer1.0", + "layer1.0.conv1", + "layer1.0.bn1", + "layer1.0.relu", + "layer1.0.conv2", + "layer1.0.bn2", + "layer1.0.relu_2", + "layer1.0.conv3", + "layer1.0.bn3", + "layer1.0.shortcut", + "layer1.0.shortcut.conv1", + "layer1.0.shortcut.bn1", + "fc" + ] + } + } +}{ + "alexnet_ambient_4": { + "model_name": "alexnet", + "keyword": "ambient", + "model_id": "alexnet_ambient_iteration=4", + "resize_size": 256, + "crop_size": 224, + "checkpoint_url": "https://eggerbernhard.ch/latest_alexnet/ambient_4.ckpt", + "model_commitment": { + "layers": [ + "conv1", + "bn1", + "relu", + "maxpool", + "layer1", + "layer1.0", + "layer1.0.conv1", + "layer1.0.bn1", + "layer1.0.relu", + "layer1.0.conv2", + "layer1.0.bn2", + "layer1.0.relu_2", + "layer1.0.conv3", + "layer1.0.bn3", + "layer1.0.shortcut", + "layer1.0.shortcut.conv1", + "layer1.0.shortcut.bn1", + "fc" + ] + } + } +} \ No newline at end of file diff --git a/brainscore_vision/models/alexnet_ambient_4/model.py b/brainscore_vision/models/alexnet_ambient_4/model.py new file mode 100644 index 000000000..c42cb69ae --- /dev/null +++ b/brainscore_vision/models/alexnet_ambient_4/model.py @@ -0,0 +1,74 @@ + +import functools +import torch +from brainscore_vision.model_helpers.activations.pytorch import PytorchWrapper, load_preprocess_images +import gdown +from torch import nn +import torchvision.models as models + + +def get_bibtex(model_identifier): + return "" + +def get_model_list(network, keyword, iteration): + return [f"alexnet_ambient_iteration=4"] + +def download_checkpoint(network, keyword, iteration): + url = f"https://eggerbernhard.ch/shreya/latest_alexnet/ambient_4.ckpt" + output = f"alexnet_ambient_iteration=4.ckpt" + gdown.download(url, output, quiet=False) + return output + +def load_checkpoint(model, checkpoint_path, network, keyword): + if checkpoint_path == "x" or keyword == "imagenet_trained": + return model + ckpt = torch.load(checkpoint_path, map_location="cpu") + ckpt2 = {} + + for keys in ckpt["state_dict"]: + k2 = keys.split("model.")[1] + ckpt2[k2] = ckpt["state_dict"][keys] + model.load_state_dict(ckpt2) + return model + +def get_model(network, keyword, iteration): + checkpoint_path = download_checkpoint(network, keyword, iteration) + pretrained = keyword == "imagenet_trained" + + model = torch.hub.load('pytorch/vision', network, pretrained=pretrained) + + if not pretrained: + model = load_checkpoint(model, checkpoint_path, network, keyword) + + preprocessing = functools.partial(load_preprocess_images, image_size=224) + activations_model = PytorchWrapper(identifier=f"alexnet_ambient_iteration=4", + model=model, + preprocessing=preprocessing) + return activations_model + +def get_layers(network, keyword, iteration): + checkpoint_path = download_checkpoint(network, keyword, iteration) + pretrained = keyword == "imagenet_trained" + + model = torch.hub.load('pytorch/vision', network, pretrained=pretrained) + + if not pretrained: + model = load_checkpoint(model, checkpoint_path, network, keyword) + + layers = [name for name, module in model.named_modules()] + return layers + +if __name__ == '__main__': + device = "cpu" + network = f"alexnet" # Example network + keyword = f"ambient" # Example keyword + iteration = f"4" # Example iteration + + url = f"https://eggerbernhard.ch/shreya/latest_alexnet/ambient_4.ckpt" + output = f"alexnet_ambient_iteration=4.ckpt" + gdown.download(url, output) + + model = get_model(network, keyword, iteration) + layers = get_layers(network, keyword, iteration) + print(f"Loaded model:", model) + print(f"Available layers:", layers) diff --git a/brainscore_vision/models/alexnet_ambient_4/setup.py b/brainscore_vision/models/alexnet_ambient_4/setup.py new file mode 100644 index 000000000..64f80c7d6 --- /dev/null +++ b/brainscore_vision/models/alexnet_ambient_4/setup.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +from setuptools import setup, find_packages + +requirements = [ + "torchvision", + "torch", + "gdown", + "pytorch_lightning", + "brainscore_vision" +] + +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', +) diff --git a/brainscore_vision/models/alexnet_ambient_4/test.py b/brainscore_vision/models/alexnet_ambient_4/test.py new file mode 100644 index 000000000..5871ed8ee --- /dev/null +++ b/brainscore_vision/models/alexnet_ambient_4/test.py @@ -0,0 +1 @@ +import pytest