Skip to content

Commit

Permalink
Merge pull request #308 from AIM-Harvard/saliency_patch
Browse files Browse the repository at this point in the history
Add saliency notebook
  • Loading branch information
surajpaib authored Nov 12, 2024
2 parents b45a498 + fca6243 commit f2c6fe2
Show file tree
Hide file tree
Showing 12 changed files with 3,347 additions and 2,003 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
run: make poetry-download

- name: Set up cache
uses: actions/cache@v2.1.6
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('poetry.lock') }}
Expand Down
30 changes: 17 additions & 13 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Auto Publish
on:
push:
branches:
- master
- main

jobs:
build:
Expand All @@ -12,28 +12,32 @@ jobs:
- name: Set up Python
uses: actions/[email protected]
with:
python-version: 3.8
python-version: 3.9

- name: Install poetry
run: make setup


- name: Install poeblix for version freezing
run: poetry self add poeblix@latest

- name: Bump version
run: |
poetry version prerelease
- name: Commit & push changes
- name: Commit changes
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add .
git commit -m "Bump version" || echo "No changes to commit"
git push
- name: Build and publish to pypi
uses: JRubics/[email protected]
- name: Push changes
run: git push

- name: Build with lockfile versions
run: poetry blixbuild --only-lock

- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
python_version: 3.8
pypi_token: ${{ secrets.PYPI_TOKEN }}
allow_poetry_pre_release: "yes"
ignore_dev_requirements: "yes"
password: ${{ secrets.PYPI_TOKEN }}
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ mypy:
.PHONY: check-safety
check-safety:
poetry check
poetry run safety check --full-report --ignore 51457 --ignore 67599
poetry run bandit -c pyproject.toml -ll --recursive fmcib tests
poetry run safety check --full-report --ignore 51457 --ignore 67599 --ignore 70612
poetry run bandit -c pyproject.toml -ll --recursive fmcib tests

.PHONY: lint
lint: test check-codestyle mypy check-safety
Expand Down
677 changes: 677 additions & 0 deletions analysis/saliency.ipynb

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/assets/images/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 10 additions & 6 deletions experiments/adaptation/fmcib_finetune.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,17 @@ system:
postprocessing:
metrics:
pred:
- "$lambda x: torch.softmax(x, 1)" # Note: Change to $lambda x: torch.sigmoid(x) for Task 2 and Task 3
# criterion:
# target: # Note: Uncomment for Task 2 and Task 3
# - "$lambda x: x.float()"
- "$lambda x: torch.softmax(x, 1)" # Note: Change to $lambda x: torch.sigmoid(x) for Task 2 and Task 3
# target: # Note: Uncomment for Task 2 and Task 3
# - "$lambda x: x.long()"
# criterion: # Note: Uncomment for Task 2 and Task 3
# pred:
# - "$lambda x: x.squeeze(1)"
# target:
# - "$lambda x: x.float()"

criterion:
_target_: torch.nn.CrossEntropyLoss # Note: Change to torch.nn.BCEWithLogitsLoss for Task 2 and Task 3
_target_: torch.nn.CrossEntropyLoss # Note: Change to torch.nn.BCEWithLogitsLoss for Task 2 and Task 3

optimizer:
_target_: torch.optim.Adam
Expand All @@ -66,7 +70,7 @@ system:
train:
- _target_: torchmetrics.AveragePrecision
task: multiclass # Note: Change to `binary` for Task 2 and Task 3 and remove num_classes below
num_classes: 8
num_classes: 8
- _target_: torchmetrics.AUROC
task: multiclass # Note: Change to `binary` for Task 2 and Task 3 and remove num_classes below
num_classes: 8
Expand Down
2 changes: 1 addition & 1 deletion fmcib/models/load_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def load(self, weights):
Raises the appropriate warnings and logs informational messages.
"""
pretrained_model = torch.load(weights, map_location=self.device)
pretrained_model = torch.load(weights, map_location=self.device, weights_only=True)

if "trunk_state_dict" in pretrained_model: # Loading ViSSL pretrained model
trained_trunk = pretrained_model["trunk_state_dict"]
Expand Down
Loading

0 comments on commit f2c6fe2

Please sign in to comment.