Skip to content

feat: add ImageNet mean replacement strategy#19

Open
dhalmazna wants to merge 4 commits into
masterfrom
feat/imagenet-mean
Open

feat: add ImageNet mean replacement strategy#19
dhalmazna wants to merge 4 commits into
masterfrom
feat/imagenet-mean

Conversation

@dhalmazna

@dhalmazna dhalmazna commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator

Context:
Adds a new masking replacement strategy that substitutes occluded regions with the ImageNet dataset mean. Under standard ImageNet normalization, this maps to a zero tensor — equivalent to replacing with the mean color.

What's Changed / Added:

  • ciao/data/replacement.py: Introduced imagenet_mean_replacement function, which returns a zero tensor of the same shape as the input (mean color after ImageNet normalization).
  • ciao/data/__init__.py: Exported the new replacement function.
  • configs/replacement/imagenet_mean.yaml: Added config entry for the new strategy.
  • README.md: Noted the new replacement option.

Related Task:
XAI-29

Summary by CodeRabbit

  • New Features

    • Added an ImageNet Mean replacement option for image data processing.
    • Exposed the new replacement method for use throughout the app.
    • Added a new replacement configuration entry so it can be selected like other options.
  • Documentation

    • Updated the README to include the new ImageNet Mean replacement method and its configuration path.

@coderabbitai

coderabbitai Bot commented Jun 3, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 50c75c0d-4701-47e6-a4d2-55a9d5cd91ca

📥 Commits

Reviewing files that changed from the base of the PR and between d31cf6d and a44b9a2.

📒 Files selected for processing (4)
  • README.md
  • ciao/data/__init__.py
  • ciao/data/replacement.py
  • configs/replacement/imagenet_mean.yaml

📝 Walkthrough

Walkthrough

Adds a new imagenet_mean_replacement function to ciao/data/replacement.py that returns torch.zeros_like(image). It is exported from ciao.data, paired with a Hydra YAML config at configs/replacement/imagenet_mean.yaml, and documented in the README.

ImageNet Mean Replacement

Layer / File(s) Summary
Function, exports, config, and docs
ciao/data/replacement.py, ciao/data/__init__.py, configs/replacement/imagenet_mean.yaml, README.md
imagenet_mean_replacement is implemented as torch.zeros_like(image), added to __all__ and module imports, registered in a Hydra partial config, and listed in the README replacement methods and project structure.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

A bunny of zeros hops into the norm,
Where ImageNet means take a sleepy form.
torch.zeros_like — so tidy, so neat,
A blank little tensor, a minimal feat.
🐇✨ The mean is replaced, the diff is complete!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding an ImageNet mean replacement strategy.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/imagenet-mean

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new ImageNet mean replacement strategy, which replaces masked regions with the dataset-level ImageNet mean color. The changes include implementing the imagenet_mean_replacement function, exposing it in the package API, adding a configuration file, and updating the README. Feedback on the implementation suggests simplifying the imagenet_mean_replacement function by using torch.zeros_like(image) instead of manually unpacking the shape and expanding a new zero tensor.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread ciao/data/replacement.py Outdated
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@dhalmazna dhalmazna self-assigned this Jun 3, 2026
@dhalmazna dhalmazna marked this pull request as ready for review June 3, 2026 10:01
@dhalmazna dhalmazna requested review from a team and Copilot June 3, 2026 10:01

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new obfuscation/replacement strategy that fills masked regions with the ImageNet dataset mean; under the project’s standard ImageNet normalization this is equivalent to a zero tensor, providing a simple dataset-level baseline replacement.

Changes:

  • Added imagenet_mean_replacement strategy in ciao/data/replacement.py (implemented as torch.zeros_like(image)).
  • Exported the new replacement strategy from ciao/data/__init__.py and added a Hydra config at configs/replacement/imagenet_mean.yaml.
  • Documented the new replacement option in README.md.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
README.md Adds the “ImageNet Mean” replacement option to user-facing documentation and lists the new config file in the structure overview.
configs/replacement/imagenet_mean.yaml Introduces a Hydra config entry targeting the new replacement callable.
ciao/data/replacement.py Implements the ImageNet-mean replacement strategy (currently zero tensor in normalized space).
ciao/data/init.py Re-exports the new replacement function via imports and __all__.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread ciao/data/replacement.py
Comment thread ciao/data/replacement.py
Comment thread README.md Outdated
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants