Skip to main content

Deep learning method for removing specular reflections from RGB images.

Project description

UnReflectAnything

Project PyPI Paper Weights Demo Wiki Licence

RGB-Only Highlight Removal by Rendering Synthetic Specular Supervision

UnReflectAnything inputs any RGB image and removes specular highlights, returning a clean diffuse-only outputs. We trained UnReflectAnything by synthetizing specularities and supervising in DINOv3 feature space.

UnReflectAnything works on both natural indoor and surgical/endoscopic domain data.


examples

Installation

pip install unreflectanything

Install UnReflectAnything as a Python Package.

The minimum required Python version is 3.11, but development and all experiments have been bases on Python 3.12.

For GPU support, make sure PyTorch comes with CUDA version for your system (see PyTorch Get Started).

Setting up

After pip-installing, you can use the unreflectanything CLI command, which is also aliased to unreflect and ura. The three commands are equivalent.

With the CLI you can already download the model weights with

unreflectanything download --weights

and some sample images with

unreflectanything download --images

Weights are stored by default in ~/.cache/unreflectanything/weights (or $XDG_CACHE_HOME/unreflectanything/weights if set ; %LOCALAPPDATA%\unreflectanything for Windows). Use --output-dir to choose another location.

Both the weights and images are stored on the HuggingFace Model Repo.

Enable shell completion

Shell completion is available for the bash and zsh shells. Run

unreflectanything completion bash

and execute the echo ... command that gets printed.

Command Line Interface

Get an overview of the available CLI endpoints with

unreflectanything --help   # alias 'unreflect --help' alias 'ura --help'

Refer to the Wiki to get detailed documentation about each endpoint. We report a summary of the available subcommands. Remember that ura is aliased to the unreflectanything command

Subcommand Description Command
inference Run inference on an image directory ura inference --input /path/to/images --output /path/to/unref_images
train Run training ura train --config config_train.yaml
test Run evaluation on a trained model ura test --config config_test.yaml
download Download checkpoint weights, sample images, notebooks ura download --weights
verify Verify weights installation and compatibility, as well as dataset directory structure ura verify --dataset /path/to/dataset
evaluate Compute metrics on output data ura evaluate --output /path/to/unref_images --gt /path/to/groundtruth_images/
completion Print shell completion (bash/zsh): ura completion bash
cite Print shell completion (bash/zsh) ura cite --bibtex

Python API

The same endpoints above are exposed as a Python API. Refer to the Wiki to get detailed documentation about each endpoint. A few examples are reported below

import unreflectanything as ura
import torch

# Get the model class (e.g. for custom setup or training)
ModelClass = ura.model()

# Get a pretrained model (torch.nn.Module) and run on batched RGB
uramodel = ura.model(pretrained=True)  # uses cached weights; run 'ura download --weights' first
images = torch.rand(2, 3, 448, 448, device="cuda")  # [B, 3, H, W], values in [0, 1]
model_out = uramodel(images)  # [B, 3, H, W] diffuse tensor

# File-based or tensor-based inference (one-shot, no model handle)
ura.inference("input.png", output="output.png")
result = ura.inference(images)  # tensor input returns tensor

# Run training or testing
ura.run_pipeline(mode="train")   # or mode="test"

# Run inference from options
options = ura.InferenceOptions(
    weights_path="path/to/full_model_weights.pt",
    input_dir="path/to/input/images",
    output_dir="path/to/output/diffuse",
)
ura.run_inference(options)

Citation

If you include UnReflectAnything in your pipline or research work, we encourage you cite our work. Get the citation entry with

unreflectanything cite --bibtex

or copy it directly from below

@misc{rota2025unreflectanythingrgbonlyhighlightremoval,
      title={UnReflectAnything: RGB-Only Highlight Removal by Rendering Synthetic Specular Supervision}, 
      author={Alberto Rota and Mert Kiray and Mert Asim Karaoglu and Patrick Ruhkamp and Elena De Momi and Nassir Navab and Benjamin Busam},
      year={2025},
      eprint={2512.09583},
      archivePrefix={arXiv},
      primaryClass={cs.CV},
      url={https://arxiv.org/abs/2512.09583}, 
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

unreflectanything-0.3.3.tar.gz (242.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

unreflectanything-0.3.3-py3-none-any.whl (260.2 kB view details)

Uploaded Python 3

File details

Details for the file unreflectanything-0.3.3.tar.gz.

File metadata

  • Download URL: unreflectanything-0.3.3.tar.gz
  • Upload date:
  • Size: 242.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for unreflectanything-0.3.3.tar.gz
Algorithm Hash digest
SHA256 9d505d8d7e3b2e2aa94a615b502798287894ddf8b4726350df70e74e11af3110
MD5 7ac6018858647f9c4085d8fc1bbf6791
BLAKE2b-256 8acdbf1dedb92799375cccf14d64050072674cc5d76cf9bad2b7bb6bcfc82b82

See more details on using hashes here.

File details

Details for the file unreflectanything-0.3.3-py3-none-any.whl.

File metadata

  • Download URL: unreflectanything-0.3.3-py3-none-any.whl
  • Upload date:
  • Size: 260.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for unreflectanything-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c355c4f039961e040c806263c9b2f6b680f33c2276847783debaf4b7fc0925e0
MD5 0f175545083165461142481d65f584be
BLAKE2b-256 18eb058291aab17c9d292d82f8d8db917ff9f33a1eddff80f8abd3a64a1e96a4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page