Metadata-Version: 2.4
Name: unreflectanything
Version: 0.3.1
Summary: Deep learning method for removing specular reflections from RGB images.
Author: Alberto Rota, Mert Kiray, Mert Asim Karaoglu, Patrick Ruhkamp, Elena De Momi, Nassir Navab, Benjamin Busam
Maintainer-email: Alberto Rota <alberto1.rota@polimi.it>
License-Expression: MIT
Project-URL: Homepage, https://github.com/alberto-rota/UnReflectAnything
Project-URL: Repository, https://github.com/alberto-rota/UnReflectAnything
Project-URL: Issues, https://github.com/alberto-rota/UnReflectAnything/issues
Keywords: computer vision,specular removal,reflection removal,deep learning
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.11
Description-Content-Type: text/markdown
Requires-Dist: debugpy==1.8.20
Requires-Dist: dill==0.4.1
Requires-Dist: dotmap==1.3.30
Requires-Dist: fvcore==0.1.5.post20221221
Requires-Dist: huggingface-hub==0.36.2
Requires-Dist: lovely-tensors==0.1.21
Requires-Dist: lpips==0.1.4
Requires-Dist: matplotlib==3.10.8
Requires-Dist: moge
Requires-Dist: natsort==8.4.0
Requires-Dist: numpy==2.4.2
Requires-Dist: pandas==3.0.0
Requires-Dist: paramiko==4.0.0
Requires-Dist: pillow==12.1.1
Requires-Dist: piq==0.8.0
Requires-Dist: protobuf==6.33.5
Requires-Dist: python-dotenv==1.2.1
Requires-Dist: pyyaml==6.0.3
Requires-Dist: rerun-sdk==0.29.1
Requires-Dist: rich==14.3.2
Requires-Dist: scikit-image==0.26.0
Requires-Dist: scikit-learn==1.8.0
Requires-Dist: scipy==1.17.0
Requires-Dist: torch==2.9.1
Requires-Dist: torchvision==0.24.1
Requires-Dist: tqdm==4.67.3
Requires-Dist: transformers
Requires-Dist: wandb==0.24.2
Provides-Extra: dev
Requires-Dist: build>=1.2; extra == "dev"
Requires-Dist: twine>=5.1; extra == "dev"

# UnReflectAnything

[![Project](https://img.shields.io/badge/Project-webpage-ff611b?logo=googlehome&logoColor=ff611b)](https://alberto-rota.github.io/UnReflectAnything/)
[![PyPI](https://img.shields.io/badge/pip%20install-PyPI-76b1f3?logo=python&logoColor=76b1f3)](https://pypi.org/project/unreflectanything/)
[![Paper](https://img.shields.io/badge/Paper-arXiv-B31B1B?logo=arxiv&logoColor=B31B1B)](https://arxiv.org/abs/2512.09583)
[![Weights](https://img.shields.io/badge/Weights-HF%20-FFD21E?logo=huggingface&logoColor=FFD21E)](https://huggingface.co/spaces/AlbeRota/UnReflectAnything)
[![Demo](https://img.shields.io/badge/Demo-HF%20-FFD21E?logo=huggingface&logoColor=FFD21E)](https://huggingface.co/AlbeRota/UnReflectAnything)
[![Wiki](https://img.shields.io/badge/Wiki-GitHub-9187FF?logo=wikipedia&logoColor=9187FF)](https://github.com/alberto-rota/UnReflectAnything/wiki)
[![Licence](https://img.shields.io/badge/License-MIT-1E811F)](https://mit-license.org/)
### 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](https://raw.githubusercontent.com/alberto-rota/UnReflectAnything/refs/heads/main/assets/header.png)

## Installation
```bash
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](https://pytorch.org/get-started/locally/)).


## 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
```bash
unreflectanything download --weights
```
and some sample images with 
```bash
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](https://huggingface.co/spaces/AlbeRota/UnReflectAnything).

## Enable shell completion
Shell completion is available for the `bash` and `zsh` shells. Run
```bash
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](https://github.com/alberto-rota/UnReflectAnything/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](https://github.com/alberto-rota/UnReflectAnything/wiki) to get detailed documentation about each endpoint. A few examples are reported below

```python
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 
```bash
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}, 
}
```
