Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 35 additions & 3 deletions .github/workflows/benchopt_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,44 @@ jobs:
benchmark-dirs: ${{ steps.find-dirs.outputs.dirs }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Find benchmark directories
id: find-dirs
run: |
# Find all directories containing an objective.py file
dirs=$(find . -maxdepth 2 -name "objective.py" -type f | xargs dirname | sed 's|./||' | jq -R -s -c 'split("\n")[:-1]')
echo "dirs=$dirs" >> $GITHUB_OUTPUT
# List all benchmark directories containing an objective.py file (plain list)
dirs_list=$(find . -maxdepth 2 -name "objective.py" -type f | xargs dirname | sed 's|./||')

# Compute a single reference range per event
ref_range=""
if [ "${{ github.event_name }}" = "pull_request" ]; then
# Ensure base branch is available and compare base...HEAD
git fetch --no-tags --prune --depth=1 origin +refs/heads/${{ github.event.pull_request.base.ref }}:refs/remotes/origin/${{ github.event.pull_request.base.ref }}
ref_range="origin/${{ github.event.pull_request.base.ref }}...HEAD"
elif [ "${{ github.event_name }}" = "push" ]; then
# Compare before..sha for the push
if [ -n "${{ github.event.before }}" ] && [ -n "${{ github.sha }}" ]; then
ref_range="${{ github.event.before }}..${{ github.sha }}"
fi
fi

# Filter directories based on changes relative to ref_range
filtered=""
if [ -n "$ref_range" ]; then
# Include only directories that have changes relative to ref_range
for d in $dirs_list; do
if git diff --name-only "$ref_range" -- "$d" | grep -q .; then
filtered="${filtered}${d}\n"
fi
done
else
# No ref_range (e.g., schedule/tag/create): include all benchmarks
filtered=$(printf "%s\n" "$dirs_list")
fi

# Build JSON array from filtered list using jq and output in GitHub Actions format
dirs_json=$(printf "%b" "$filtered" | sed '/^$/d' | jq -R -s -c 'split("\n")[:-1]')
echo "dirs=$dirs_json" >> $GITHUB_OUTPUT

benchopt_dev:
needs: find-benchmarks
Expand Down
1 change: 1 addition & 0 deletions benchmark_template/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ plot_configs: # add here configurations for plotting each metric
metric: NIQE
scale: linear
# add more plot configurations as needed
data_home: "../data"
16 changes: 8 additions & 8 deletions benchmark_template/datasets/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,29 @@ class Dataset(BaseDataset):
# IMPORTANT: the names of physics and noise should match
# the ones defined in deepinv.physics with exact same spelling
parameters = {
'physics' : ['physics_name'],
'noise' : ['noise_name'],
'physics': ['physics_name'],
'noise': ['noise_name'],
'img_size': [256],
# add any other parameter you might need
}

requirements = ["datasets"]

def get_data(self):
root = get_data_path("DIV2K")
root = get_data_path("Set14_HR")

transform = transforms.Compose([
transforms.Resize((self.img_size, self.img_size)),
transforms.ToTensor()
])

# load the dataset
dataset = dinv.datasets.DIV2K(
root, mode="val", download=True, transform=transform
dataset = dinv.datasets.Set14HR(
root, download=True, transform=transform
)

# define the physics according to the parameters
physics = dinv.physics.Denoising(noise_model=dinv.physics.GaussianNoise())
physics = dinv.physics.Denoising(
noise_model=dinv.physics.GaussianNoise()
)

return dict(
dataset=dataset,
Expand Down
10 changes: 8 additions & 2 deletions benchmark_template/objective.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Objective(BaseObjective):

url = "https://github.com/deep-inverse/benchmarks"

requirements = ["deepinv"]
requirements = ["deepinv", "datasets", "pip:pyiqa"]

# Minimal version of benchopt required to run this benchmark.
# Bump it up if the benchmark depends on a new feature of benchopt.
Expand Down Expand Up @@ -46,7 +46,13 @@ def evaluate_result(self, model):
return results

def get_one_result(self):
return dict(model=lambda x: x)
class DummyModel:
def eval(self): pass

def __call__(self, x, physics=None):
return physics.A_adjoint(x)

return dict(model=DummyModel())

def get_objective(self):
return dict(
Expand Down
2 changes: 1 addition & 1 deletion benchmark_template/solvers/solver1.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def set_objective(self, train_dataset=None, physics=None):
)

# replace by your model, should take (y, physics) as input
self.model = dinv.models.RAM(device=device)
self.model = dinv.models.DnCNN(device=device)
self.model.device = device

def run(self, _):
Expand Down
1 change: 1 addition & 0 deletions cbsd500_gaussian_denoising/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ plot_configs:
plot_kind: deepinv_boxplot
metric: NIQE
scale: linear
data_home: "../data"
6 changes: 2 additions & 4 deletions cbsd500_gaussian_denoising/datasets/cbsd68.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class Dataset(BaseDataset):

name = "CBSD68"
parameters = {
'physics' : ['Denoising'],
'noise' : ['GaussianNoise'],
'physics': ['Denoising'],
'noise': ['GaussianNoise'],
'sigma': [0.1],
'img_size': [256],
'debug': [False],
Expand All @@ -25,8 +25,6 @@ class Dataset(BaseDataset):
"debug": [True]
}

requirements = ["datasets"]

def get_data(self):

root = get_data_path("CBSD68")
Expand Down
2 changes: 1 addition & 1 deletion cbsd500_gaussian_denoising/objective.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Objective(BaseObjective):

url = "https://github.com/deep-inverse/benchmarks"

requirements = ["deepinv"]
requirements = ["deepinv", "datasets", "pip:pyiqa"]

# Minimal version of benchopt required to run this benchmark.
# Bump it up if the benchmark depends on a new feature of benchopt.
Expand Down
1 change: 1 addition & 0 deletions div2k_gaussian_deblurring/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ plot_configs:
plot_kind: deepinv_boxplot
metric: NIQE
scale: linear
data_home: "../data"
6 changes: 2 additions & 4 deletions div2k_gaussian_deblurring/datasets/div2k.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class Dataset(BaseDataset):

name = "DIV2K"
parameters = {
'physics' : ['Blur'],
'noise' : ['GaussianNoise'],
'physics': ['Blur'],
'noise': ['GaussianNoise'],
'sigma': [0.1],
'img_size': [256],
'debug': [False],
Expand All @@ -25,8 +25,6 @@ class Dataset(BaseDataset):
"debug": [True]
}

requirements = ["datasets"]

def get_data(self):
root = get_data_path("DIV2K")
transform = transforms.Compose([
Expand Down
2 changes: 1 addition & 1 deletion div2k_gaussian_deblurring/objective.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Objective(BaseObjective):

url = "https://github.com/deep-inverse/benchmarks"

requirements = ["deepinv"]
requirements = ["deepinv", "datasets", "pip:pyiqa"]

# Minimal version of benchopt required to run this benchmark.
# Bump it up if the benchmark depends on a new feature of benchopt.
Expand Down
Loading