Instructions to use BiliSakura/IntrisicWeather-diffusers with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use BiliSakura/IntrisicWeather-diffusers with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("BiliSakura/IntrisicWeather-diffusers", dtype=torch.bfloat16, device_map="cuda") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
File size: 9,457 Bytes
c5cfae9 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 | # IntrinsicWeather (Diffusers)
Diffusers-format checkpoint for **[IntrinsicWeather: Controllable Weather Editing in Intrinsic Space](https://arxiv.org/pdf/2508.06982v6)** (CVPR 2026 Highlight).
This repo bundles inverse rendering, forward weather rendering, and the IMAA gating module into a single Hugging Faceβcompatible layout. Shared Stable Diffusion 3 components (VAE, text encoders, tokenizers, scheduler) are stored once; task-specific transformers live under `transformer/<variant>/`.
## Model layout
```
IntrisicWeather-diffusers/
βββ dinov2/ # bundled DINOv2 weights (for IMAA / decomposition)
βββ imaa/ # Intrinsic Map-Aware Attention weights
βββ text_encoder/, text_encoder_2/, text_encoder_3/
βββ tokenizer/, tokenizer_2/, tokenizer_3/
βββ vae/, scheduler/
βββ transformer/
β βββ inverse-512/ # IntrinsicWeatherSD3Transformer2DModel (in_channels=32)
β β βββ transformer_intrinsic_weather.py
β βββ forward/ # SD3Transformer2DModel (in_channels=96)
β βββ lora/ # forward-renderer LoRA (loaded by default)
βββ pipeline_intrinsic_weather.py # unified: RGB β maps β weather RGB
βββ pipeline_intrinsic_weather_inverse.py # inverse only
βββ pipeline_intrinsic_weather_forward.py # forward only
βββ pipeline_utils.py
βββ model_index.json
βββ convert_inverse_renderer_512.py
βββ convert_forward_renderer.py
βββ test_all_pipelines.py
```
| Component | Source | Notes |
|-----------|--------|-------|
| Inverse transformer | [GilgameshYX/InverseRenderer-512](https://huggingface.co/GilgameshYX/InverseRenderer-512) | 512Γ512 decomposition |
| Forward transformer + LoRA | [GilgameshYX/ForwardRenderer](https://huggingface.co/GilgameshYX/ForwardRenderer) | LoRA in `transformer/forward/lora/` |
| IMAA | InverseRenderer-512 `imaa.pth` | Required for map-aware inverse attention |
| SD3 shared weights | `stabilityai/stable-diffusion-3-medium-diffusers` | VAE + text encoders only |
| Transformer config | `stabilityai/stable-diffusion-3.5-medium` | Architecture template for weight loading |
## Requirements
- Python 3.10+
- CUDA GPU recommended (~20 GB VRAM for full end-to-end inference at 512Γ512)
- `torch`, `diffusers>=0.38`, `transformers`, `safetensors`, `torchvision`, `Pillow`
```bash
pip install torch diffusers transformers safetensors torchvision pillow accelerate
```
## Quick start (end-to-end weather edit)
The unified pipeline decomposes an input RGB image into intrinsic maps, then renders a weather-conditioned result. **DINOv2** is required for decomposition (bundled under `dinov2/`, or use `facebook/dinov2-base` from Hugging Face).
```python
from pathlib import Path
import torch
from PIL import Image
from transformers import AutoImageProcessor, AutoModel
from pipeline_intrinsic_weather import IntrinsicWeatherPipeline
repo_dir = Path(".").resolve() # path to this folder
device = "cuda"
dtype = torch.bfloat16
pipe = IntrinsicWeatherPipeline.from_pretrained(
repo_dir,
inverse_transformer_subfolder="inverse-512",
forward_transformer_subfolder="forward",
device=device,
local_files_only=True,
torch_dtype=dtype,
load_lora=True,
load_imaa=True,
)
dino_path = repo_dir / "dinov2"
dino_processor = AutoImageProcessor.from_pretrained(dino_path, local_files_only=True)
dino_model = AutoModel.from_pretrained(dino_path, local_files_only=True).to(device)
dino_model.eval()
image = Image.open("input.png").convert("RGB")
result = pipe(
image=image,
weather="snowy", # rainy | sunny | snowy | foggy | overcast | night
dino_model=dino_model,
dino_processor=dino_processor,
image_size=512,
render_size=512,
num_inverse_steps=50,
num_forward_steps=50,
guidance_scale=6.0,
image_guidance_scale=1.5,
generator=torch.Generator(device=device).manual_seed(42),
)
result.images[0].save("output_snowy.png")
```
Run from inside this directory (or add it to `PYTHONPATH`) so `pipeline_intrinsic_weather.py` and `imaa/` resolve correctly.
## Pipelines
### 1. `IntrinsicWeatherPipeline` (unified)
Full pipeline: **RGB β intrinsic maps β weather RGB**.
```python
pipe = IntrinsicWeatherPipeline.from_pretrained(
repo_dir,
inverse_transformer_subfolder="inverse-512",
forward_transformer_subfolder="forward",
device="cuda",
torch_dtype=torch.bfloat16,
)
```
Useful kwargs:
| Argument | Default | Description |
|----------|---------|-------------|
| `inverse_transformer_subfolder` | `"inverse-512"` | Inverse transformer under `transformer/` |
| `forward_transformer_subfolder` | `"forward"` | Forward transformer under `transformer/` |
| `load_lora` | `True` | Load LoRA from `transformer/forward/lora/` |
| `load_imaa` | `True` | Load IMAA weights from `imaa/` |
| `device` | `None` | Moves all modules to device (IMAA stays float32) |
Sub-methods:
- `pipe.decompose(image, dino_model, dino_processor, ...)` β dict of intrinsic maps
- `pipe.render(maps, weather="rainy", ...)` β weather-conditioned RGB
### 2. `IntrinsicWeatherInversePipeline`
Inverse rendering only (single intrinsic map per call).
```python
from pipeline_intrinsic_weather_inverse import IntrinsicWeatherInversePipeline
pipe = IntrinsicWeatherInversePipeline.from_pretrained(
repo_dir,
transformer_subfolder="inverse-512",
device="cuda",
torch_dtype=torch.bfloat16,
)
```
Load the transformer separately if needed:
```python
transformer = IntrinsicWeatherInversePipeline.load_transformer(
"inverse-512", repo_dir, device="cuda"
)
pipe = IntrinsicWeatherInversePipeline.from_pretrained(
repo_dir, transformer=transformer, device="cuda"
)
```
IMAA and DINO are used by the unified pipelineβs `decompose()` path; for standalone inverse calls, pass `map_aware_mask` from IMAA manually (see `test_all_pipelines.py`).
### 3. `IntrinsicWeatherForwardPipeline`
Forward weather rendering from intrinsic maps.
```python
from pipeline_intrinsic_weather_forward import IntrinsicWeatherForwardPipeline
pipe = IntrinsicWeatherForwardPipeline.from_pretrained(
repo_dir,
transformer_subfolder="forward",
device="cuda",
torch_dtype=torch.bfloat16,
load_lora=True,
)
```
LoRA weights are read from `transformer/forward/lora/` when `load_lora=True`.
## Weather presets
Built-in weather keys (or pass a custom prompt string):
| Key | Prompt |
|-----|--------|
| `rainy` | A rainy day. |
| `sunny` | A sunny day. |
| `snowy` | A snowy day. |
| `foggy` | A foggy day. |
| `overcast` | An overcast day. |
| `night` | A night scene. |
## Intrinsic maps (AoVs)
The inverse renderer produces five appearance-of-variety maps:
`albedo`, `normal`, `roughness`, `metallic`, `irradiance`
## Loading transformers manually
Transformers are stored per variant under `transformer/<subfolder>/`. Use `pipeline_utils.load_transformer_from_subfolder`:
```python
from pipeline_utils import load_transformer_from_subfolder, load_transformer_lora
inverse = load_transformer_from_subfolder(repo_dir, "inverse-512", device="cuda")
forward = load_transformer_from_subfolder(repo_dir, "forward", device="cuda")
```
- `inverse-512` uses a custom `IntrinsicWeatherSD3Transformer2DModel` (`in_channels=32`).
- `forward` uses the standard `SD3Transformer2DModel` (`in_channels=96`).
## Dtype and device notes
- Default dtype is **`torch.bfloat16`** for transformers, VAE, and text encoders.
- **IMAA** stays in **float32** (DINO patch tokens are float32).
- Pass `device="cuda"` to `from_pretrained` on all three pipeline classes; the unified pipeline moves every registered module to the target device automatically.
## Testing
Smoke-test all pipelines on CUDA:
```bash
python test_all_pipelines.py
```
Runs 2-step inverse, forward (with LoRA), and unified load checks with `bfloat16`.
## Re-converting from original checkpoints
If you have the raw GilgameshYX checkpoints:
```bash
# Inverse renderer (512) + IMAA
python convert_inverse_renderer_512.py
# Forward renderer + LoRA
python convert_forward_renderer.py
```
See `conversion_metadata.json` and `conversion_metadata_forward.json` for source paths used during conversion.
## Hugging Face Hub loading
When published to the Hub, load with `trust_remote_code=True`:
```python
from diffusers import DiffusionPipeline
pipe = DiffusionPipeline.from_pretrained(
"BiliSakura/IntrisicWeather-diffusers",
custom_pipeline="pipeline_intrinsic_weather.py",
trust_remote_code=True,
torch_dtype=torch.bfloat16,
)
```
For local use, importing `IntrinsicWeatherPipeline` directly (as in Quick start) is simpler and avoids Hub cache path issues with custom modules.
## References
- **Paper:** [IntrinsicWeather (arXiv:2508.06982)](https://arxiv.org/pdf/2508.06982v6)
- **Project page:** https://yixinzhu042.github.io/IntrinsicWeather/
- **Upstream diffusers repo:** [IntrinsicWeather-diffusers](https://github.com/YixinZhu042/IntrinsicWeather)
- **Original weights:** [GilgameshYX/InverseRenderer-512](https://huggingface.co/GilgameshYX/InverseRenderer-512), [GilgameshYX/ForwardRenderer](https://huggingface.co/GilgameshYX/ForwardRenderer)
## License
Weights and code follow the licenses of the upstream IntrinsicWeather project and the Stable Diffusion 3 components used for shared modules.
|