Upload weights, notebooks, sample images
Browse files
README.md
CHANGED
|
@@ -1,114 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
# UnReflectAnything
|
| 2 |
|
| 3 |
[](https://alberto-rota.github.io/UnReflectAnything/)
|
| 4 |
-
[]
|
| 5 |
[](https://arxiv.org/abs/2512.09583)
|
| 6 |
[](https://huggingface.co/spaces/AlbeRota/UnReflectAnything)
|
| 7 |
[](https://huggingface.co/AlbeRota/UnReflectAnything)
|
| 8 |
[](https://github.com/alberto-rota/UnReflectAnything/wiki)
|
| 9 |
[](https://mit-license.org/)
|
| 10 |
-
### RGB-Only Highlight Removal by Rendering Synthetic Specular Supervision
|
| 11 |
-
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.
|
| 12 |
|
|
|
|
| 13 |
|
| 14 |
UnReflectAnything works on both natural indoor and surgical/endoscopic domain data.
|
| 15 |
|
| 16 |
---
|
| 17 |
-

|
| 18 |
|
| 19 |
-
##
|
| 20 |
-
|
| 21 |
-
pip install unreflectanything
|
| 22 |
-
```
|
| 23 |
-
Install UnReflectAnything as a Python Package.
|
| 24 |
|
| 25 |
-
The minimum required Python version is 3.11, but development and all experiments have been bases on **Python 3.12**.
|
| 26 |
|
| 27 |
-
For GPU support, make sure PyTorch comes with CUDA version for your system (see [PyTorch Get Started](https://pytorch.org/get-started/locally/)).
|
| 28 |
|
|
|
|
| 29 |
|
| 30 |
-
|
| 31 |
-
After pip-installing, you can use the `unreflectanything` CLI command, which is also aliased to `unreflect` and `ura`. The three commands are equivalent.
|
| 32 |
|
| 33 |
-
|
| 34 |
-
```bash
|
| 35 |
-
unreflectanything download --weights
|
| 36 |
-
```
|
| 37 |
-
and some sample images with
|
| 38 |
-
```bash
|
| 39 |
-
unreflectanything download --images
|
| 40 |
-
```
|
| 41 |
|
| 42 |
-
|
| 43 |
|
| 44 |
-
|
| 45 |
|
| 46 |
-
|
| 47 |
-
Shell completion is available for the `bash` and `zsh` shells. Run
|
| 48 |
-
```bash
|
| 49 |
-
unreflectanything completion bash
|
| 50 |
-
```
|
| 51 |
-
and execute the `echo ...` command that gets printed.
|
| 52 |
|
|
|
|
|
|
|
| 53 |
|
| 54 |
-
|
| 55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
```
|
| 57 |
-
|
|
|
|
|
|
|
| 58 |
```
|
| 59 |
-
|
| 60 |
|
| 61 |
-
|
| 62 |
-
|------------|-------------|-------------|
|
| 63 |
-
| `inference` | Run inference on an image directory |`ura inference --input /path/to/images --output /path/to/unref_images` |
|
| 64 |
-
| `train` | Run training | `ura train --config config_train.yaml`|
|
| 65 |
-
| `test` | Run evaluation on a trained model |`ura test --config config_test.yaml`|
|
| 66 |
-
| `download` | Download checkpoint weights, sample images, notebooks |`ura download --weights`|
|
| 67 |
-
| `verify` | Verify weights installation and compatibility, as well as dataset directory structure | `ura verify --dataset /path/to/dataset`|
|
| 68 |
-
| `evaluate` | Compute metrics on output data | `ura evaluate --output /path/to/unref_images --gt /path/to/groundtruth_images/`|
|
| 69 |
-
| `completion` | Print shell completion (bash/zsh): |`ura completion bash` |
|
| 70 |
-
| `cite` | Print shell completion (bash/zsh)| `ura cite --bibtex` |
|
| 71 |
-
|
| 72 |
-
## Python API
|
| 73 |
|
| 74 |
-
|
| 75 |
|
| 76 |
```python
|
| 77 |
-
import unreflectanything
|
| 78 |
import torch
|
| 79 |
|
| 80 |
-
#
|
| 81 |
-
|
| 82 |
|
| 83 |
-
#
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
model_out = uramodel(images) # [B, 3, H, W] diffuse tensor
|
| 87 |
|
| 88 |
-
#
|
| 89 |
-
|
| 90 |
-
|
|
|
|
| 91 |
|
| 92 |
-
|
| 93 |
-
ura.run_pipeline(mode="train") # or mode="test"
|
| 94 |
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
ura
|
| 102 |
-
|
|
|
|
|
|
|
|
|
|
| 103 |
|
| 104 |
## Citation
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
```
|
| 110 |
-
or copy it directly from below
|
| 111 |
-
```
|
| 112 |
@misc{rota2025unreflectanythingrgbonlyhighlightremoval,
|
| 113 |
title={UnReflectAnything: RGB-Only Highlight Removal by Rendering Synthetic Specular Supervision},
|
| 114 |
author={Alberto Rota and Mert Kiray and Mert Asim Karaoglu and Patrick Ruhkamp and Elena De Momi and Nassir Navab and Benjamin Busam},
|
|
@@ -116,6 +110,9 @@ or copy it directly from below
|
|
| 116 |
eprint={2512.09583},
|
| 117 |
archivePrefix={arXiv},
|
| 118 |
primaryClass={cs.CV},
|
| 119 |
-
url={https://arxiv.org/abs/2512.09583},
|
| 120 |
}
|
|
|
|
| 121 |
```
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
tags:
|
| 4 |
+
- image-to-image
|
| 5 |
+
- reflection-removal
|
| 6 |
+
- highlight-removal
|
| 7 |
+
- computer-vision
|
| 8 |
+
- dinov3
|
| 9 |
+
- surgical-imaging
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
# UnReflectAnything
|
| 13 |
|
| 14 |
[](https://alberto-rota.github.io/UnReflectAnything/)
|
| 15 |
+
[](https://pypi.org/project/unreflectanything/)
|
| 16 |
[](https://arxiv.org/abs/2512.09583)
|
| 17 |
[](https://huggingface.co/spaces/AlbeRota/UnReflectAnything)
|
| 18 |
[](https://huggingface.co/AlbeRota/UnReflectAnything)
|
| 19 |
[](https://github.com/alberto-rota/UnReflectAnything/wiki)
|
| 20 |
[](https://mit-license.org/)
|
|
|
|
|
|
|
| 21 |
|
| 22 |
+
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.
|
| 23 |
|
| 24 |
UnReflectAnything works on both natural indoor and surgical/endoscopic domain data.
|
| 25 |
|
| 26 |
---
|
|
|
|
| 27 |
|
| 28 |
+
## Architecture
|
| 29 |
+

|
|
|
|
|
|
|
|
|
|
| 30 |
|
|
|
|
| 31 |
|
|
|
|
| 32 |
|
| 33 |
+
* **<font color="#a001e0">Encoder</font> ($\mathit{\textcolor{a001e0}{E}}$ )**: Processes the input image $\mathbf{I}$ to extract a rich latent representation, $\mathbf{F}_\ell$. This is the off-the-shelf pretrained [DINOv3-large](https://huggingface.co/facebook/dinov3-vitl16-pretrain-lvd1689m)
|
| 34 |
|
| 35 |
+
* **<font color="#0167ff">Reflection Predictor</font> ($\mathit{\textcolor{0167ff}{H}}$ )**: Predicts a soft highlight mask (**H**), identifying areas of specular highlights.
|
|
|
|
| 36 |
|
| 37 |
+
* **Masking Operation</font> ($\mathit{P}$ )**: A binary mask **P** is derived from the prediction and applied to the feature map: $(1-\mathbf{P}) \odot \mathbf{F}_\ell$. This removes features contaminated by reflections, leaving "holes" in the data.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
+
* **<font color="#23ac2c">Token Inpainter</font> ($\mathit{\textcolor{23ac2c}{T}}$ )**: Acts as a neural in-painter. It processes the masked features and uses the surrounding clean context prior and a learned mask token to synthesize the missing information in embedding space, producing the completed feature map $\mathbf{F}_{\text{comp}}$.
|
| 40 |
|
| 41 |
+
* **<font color="#ff7700">Decoder</font> ($\mathit{\textcolor{ff7700}{D}}$ )**: Project the completed features back into the pixel space to generate the final, reflection-free image $\mathbf{I}_{\text{diff}}$.
|
| 42 |
|
| 43 |
+
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
+
## Training Strategy
|
| 46 |
+
We train UnReflectAnything with **Synthetic Specular Supervision** by inferring 3D geometry from [MoGe-2](https://wangrc.site/MoGe2Page/) and rendering highlights with a Blinn-Phong reflection model. We randomly sample the light source position in 3D space at every training iteration enhance etherogeneity.
|
| 47 |
|
| 48 |
+

|
| 49 |
+
|
| 50 |
+
We train the model in two stages
|
| 51 |
+
1. **DPT Decoder Pre-Training**: The **<font color="#ff7700">Decoder</font>** is first pre-trained in an autoencoder configuration ($\min_{\theta} \mathcal{L}(M_{\theta}(\mathbf{I}), \mathbf{I})$) to ensure it can reconstruct realistic RGB textures from the DINOV3 latent space.
|
| 52 |
+
2. **End-to-End Refinement**: The full pipeline is then trained to predict reflection masks from $\mathit{\textcolor{0167ff}{H}}$, and fill them using the **<font color="#38761D">Token Inpainter</font>**, ensuring the final output is both visually consistent and physically accurate. The decoder is also fine-tuned at this stage
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
## Weights
|
| 57 |
+
Install the API and CLI on a **Python>=3.11** environment with
|
| 58 |
+
```bash
|
| 59 |
+
pip install unreflectanything
|
| 60 |
```
|
| 61 |
+
then run
|
| 62 |
+
```bash
|
| 63 |
+
unreflectanything download --weights
|
| 64 |
```
|
| 65 |
+
to download the `.pth` weights in the package cache dir. The cache dir is usually at `.cache/unreflectanything`
|
| 66 |
|
| 67 |
+
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
|
| 69 |
+
### Basic Python Usage
|
| 70 |
|
| 71 |
```python
|
| 72 |
+
import unreflectanything
|
| 73 |
import torch
|
| 74 |
|
| 75 |
+
# Load the pretrained model (uses cached weights)
|
| 76 |
+
unreflect_model = unreflectanything.model()
|
| 77 |
|
| 78 |
+
# Run inference on a tensor [B, 3, H, W] in range [0, 1]
|
| 79 |
+
images = torch.rand(2, 3, 448, 448).cuda()
|
| 80 |
+
diffuse_output = unreflect_model(images)
|
|
|
|
| 81 |
|
| 82 |
+
# Simple file-based inference
|
| 83 |
+
unreflectanything.inference("input_with_highlights.png", output="diffuse_result.png")
|
| 84 |
+
```
|
| 85 |
+
Refer to the [Wiki](https://github.com/alberto-rota/UnReflectAnything/wiki) for all details on the API endpoints
|
| 86 |
|
| 87 |
+
---
|
|
|
|
| 88 |
|
| 89 |
+
### CLI Overview
|
| 90 |
+
|
| 91 |
+
The package provides a comprehensive command-line interface via `ura`, `unreflect`, or `unreflectanything`.
|
| 92 |
+
|
| 93 |
+
* **Inference**: `ura inference --input /path/to/images --output /path/to/output`
|
| 94 |
+
* **Evaluation**: `ura evaluate --output /path/to/results --gt /path/to/groundtruth`
|
| 95 |
+
* **Verification**: `ura verify --dataset /path/to/dataset`
|
| 96 |
+
|
| 97 |
+
Refer to the [Wiki](https://github.com/alberto-rota/UnReflectAnything/wiki) for all details on the CLI endpoints
|
| 98 |
+
|
| 99 |
+
---
|
| 100 |
|
| 101 |
## Citation
|
| 102 |
+
|
| 103 |
+
If you use UnReflectAnything in your research or pipeline, please cite our paper:
|
| 104 |
+
|
| 105 |
+
```bibtex
|
|
|
|
|
|
|
|
|
|
| 106 |
@misc{rota2025unreflectanythingrgbonlyhighlightremoval,
|
| 107 |
title={UnReflectAnything: RGB-Only Highlight Removal by Rendering Synthetic Specular Supervision},
|
| 108 |
author={Alberto Rota and Mert Kiray and Mert Asim Karaoglu and Patrick Ruhkamp and Elena De Momi and Nassir Navab and Benjamin Busam},
|
|
|
|
| 110 |
eprint={2512.09583},
|
| 111 |
archivePrefix={arXiv},
|
| 112 |
primaryClass={cs.CV},
|
| 113 |
+
url={[https://arxiv.org/abs/2512.09583](https://arxiv.org/abs/2512.09583)},
|
| 114 |
}
|
| 115 |
+
|
| 116 |
```
|
| 117 |
+
|
| 118 |
+
---
|