Deep learning method for removing specular reflections from RGB images.
Project description
UnReflectAnything
RGB-Only Highlight Removal by Rendering Synthetic Specular Supervision
UnReflectAnything inputs any RGB image and removes specular highlights, returning a clean diffuse-only outputs. UnReflectAnything works on both natural indoor and surgical/endoscopic domain data.
Installation
pip install unreflectanything
Install UnReflectAnything from PyPI. Python 3.12 is recommended.
For GPU support, make sure PyTorch comes with CUDA version for your system (see PyTorch Get Started).
Setting up
Pretrained weights are not included in the package. After installing, download them once:
unreflectanything download-weights
Weights are stored by default in ~/.cache/unreflectanything/weights (or $XDG_CACHE_HOME/unreflectanything/weights if set). Use --output-dir to choose another location. To use a custom weights repository (e.g. on Hugging Face), set the environment variable UNREFLECTANYTHING_WEIGHTS_REPO.
For the download command to work, install the optional dependency: pip install unreflectanything[weights].
CLI usage
After installation you get the unreflectanything command (aliases: unreflect, ura; all three do the same thing). For development, use pip install -e . so the same entry points work from the repo.
| Subcommand | Description |
|---|---|
train |
Run training (e.g. unreflectanything train --config config_train.yaml) |
test |
Run evaluation (unreflectanything test --config config_test.yaml) |
inference |
Run inference on an image directory (unreflectanything inference --input /images --output /unref_images) |
download |
Download checkpoint weights |
sweep |
Launch a Weights & Biases sweep |
agent |
Run a W&B sweep agent |
completion |
Print shell completion (bash/zsh): source <(unreflectanything completion bash) |
Inference expects a YAML config with weights_path, input_dir, output_dir, and other options (see config_inference.yaml). You can point weights_path to the cache directory after running download-weights.
Python API
Use the package programmatically:
import unreflectanything as ura
# Run training or testing
ura.run_pipeline(mode="train") # or mode="test"
# Run inference from options
from pathlib import Path
from unreflectanything import InferenceOptions, run_inference
options = InferenceOptions(
weights_path=Path("path/to/full_model_weights.pt"),
input_dir=Path("input/images"),
output_dir=Path("output/diffuse"),
)
ura.run_inference(options)
# Utility: compute highlight mask from RGB batch [B,3,H,W]
import torch
mask = ura.compute_highlight_mask(rgb_batch, threshold=0.7) # [B,1,H,W]
# Default weights cache directory
cache_dir = ura.get_weights_cache_dir()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file unreflectanything-0.1.6.tar.gz.
File metadata
- Download URL: unreflectanything-0.1.6.tar.gz
- Upload date:
- Size: 263.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
39af8dac7363e1449e5f9330fdc3e717ccea5aef60799e2ed3f11e6e2667a9fd
|
|
| MD5 |
1bfbd52b3c390413a30ff36c41d6b928
|
|
| BLAKE2b-256 |
179f00652155befc160cde6106bcffcf0f2c094a4e83ab6b8b6a7ba1749e1b5a
|
File details
Details for the file unreflectanything-0.1.6-py3-none-any.whl.
File metadata
- Download URL: unreflectanything-0.1.6-py3-none-any.whl
- Upload date:
- Size: 279.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
538bdfac31ccf7e72f246952f523580e101d130a2d81be722dae1f6f20a0db3f
|
|
| MD5 |
0d2e987ac10d849c1fc1df513ce58cc9
|
|
| BLAKE2b-256 |
5f4c2f17a3f3c87ad949f97e751bb2e4f52caa326e922f87a974d669ba36b026
|