Text-to-Image
Diffusers
TensorBoard
Safetensors
diffusion
stable-diffusion
stable-diffusion-3
controlnet
causal-inference
counterfactual-generation
causal-adapter
Instructions to use LeiTong/Causal-Adapter with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use LeiTong/Causal-Adapter with Diffusers:
pip install -U diffusers transformers accelerate
from diffusers import ControlNetModel, StableDiffusionControlNetPipeline controlnet = ControlNetModel.from_pretrained("LeiTong/Causal-Adapter") pipe = StableDiffusionControlNetPipeline.from_pretrained( "lambda/miniSD-diffusers,stabilityai/stable-diffusion-3-medium-diffusers", controlnet=controlnet ) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Draw Things
- DiffusionBee
Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
下面是完整 Markdown,可直接复制到 HF README:
|
| 2 |
+
|
| 3 |
+
````markdown
|
| 4 |
+
---
|
| 5 |
+
base_model:
|
| 6 |
+
- lambda/miniSD-diffusers
|
| 7 |
+
- stabilityai/stable-diffusion-3-medium-diffusers
|
| 8 |
+
license: apache-2.0
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
# Causal-Adapter Pretrained Weights
|
| 12 |
+
|
| 13 |
+
## Model Overview
|
| 14 |
+
|
| 15 |
+
This repository provides pretrained Causal-Adapter weights across four benchmark settings. The released checkpoints include Causal-Adapter models built on both SD1.5-style and SD3-style diffusion structures.
|
| 16 |
+
|
| 17 |
+
Causal-Adapter is designed to inject structured causal semantics into pretrained text-to-image diffusion models for controllable and causally consistent counterfactual image generation.
|
| 18 |
+
|
| 19 |
+
Detailed usage examples are available in our notebook benchmarks:
|
| 20 |
+
|
| 21 |
+
[Notebook Benchmarks](https://github.com/LeiTong02/Causal-Adapter/tree/main/notebook_benchmarks)
|
| 22 |
+
|
| 23 |
+
An example configuration can be found in:
|
| 24 |
+
|
| 25 |
+
```text
|
| 26 |
+
notebook_benchmarks/counterfactuals_celeba.ipynb
|
| 27 |
+
````
|
| 28 |
+
|
| 29 |
+
## Base Models
|
| 30 |
+
|
| 31 |
+
The released checkpoints are based on the following pretrained diffusion backbones:
|
| 32 |
+
|
| 33 |
+
* **SD1.5-style structure:** `lambda/miniSD-diffusers`
|
| 34 |
+
* **SD3-style structure:** `stabilityai/stable-diffusion-3-medium-diffusers`
|
| 35 |
+
|
| 36 |
+
## Benchmark Resources
|
| 37 |
+
|
| 38 |
+
* **Pendulum dataset generation:**
|
| 39 |
+
[CausalVAE Pendulum](https://github.com/huawei-noah/trustworthyAI/blob/master/research/CausalVAE/causal_data/pendulum.py)
|
| 40 |
+
|
| 41 |
+
* **CelebA and ADNI benchmark configuration:**
|
| 42 |
+
[counterfactual-benchmark](https://github.com/gulnazaki/counterfactual-benchmark)
|
| 43 |
+
|
| 44 |
+
* **CelebA-HQ dataset:**
|
| 45 |
+
[CelebAMask-HQ](https://github.com/switchablenorms/CelebAMask-HQ)
|
| 46 |
+
|
| 47 |
+
## Example Configuration
|
| 48 |
+
|
| 49 |
+
The following example shows the main paths required for running the CelebA counterfactual generation notebook.
|
| 50 |
+
|
| 51 |
+
```python
|
| 52 |
+
import os
|
| 53 |
+
|
| 54 |
+
# Shared roots
|
| 55 |
+
|
| 56 |
+
# 1) Frozen SD1.5 backbone.
|
| 57 |
+
# For example: "lambda/miniSD-diffusers"
|
| 58 |
+
BASE_MODEL_PATH = ""
|
| 59 |
+
|
| 60 |
+
# 2) Causal-Adapter ControlNet checkpoint and the matching MCPL learned pseudo-tokens.
|
| 61 |
+
# Example ControlNet checkpoint:
|
| 62 |
+
# https://huggingface.co/LeiTong/Causal-Adapter/tree/main/celeba/controlnet/controlnet-steps-200000.safetensors
|
| 63 |
+
CONTROLNET_PATH = ""
|
| 64 |
+
|
| 65 |
+
# Example learned text embeddings:
|
| 66 |
+
# https://huggingface.co/LeiTong/Causal-Adapter/tree/main/celeba/controlnet/learned_embeds-steps-200000.safetensors
|
| 67 |
+
TEXT_EMBEDDING_PATH = ""
|
| 68 |
+
|
| 69 |
+
# 3) Optional pretrained SCM head from SCM_modeling/.
|
| 70 |
+
# Example SCM checkpoint:
|
| 71 |
+
# https://huggingface.co/LeiTong/Causal-Adapter/tree/main/celeba/scm/best_model.pt
|
| 72 |
+
SCM_PATH = ""
|
| 73 |
+
|
| 74 |
+
# 4) CelebA root expected by torchvision.datasets.CelebA(root=...).
|
| 75 |
+
DATA_ROOT = os.environ.get("DATA_ROOT", "")
|
| 76 |
+
|
| 77 |
+
DATASET = "celeA_complex"
|
| 78 |
+
SIZE = 256
|
| 79 |
+
```
|
| 80 |
+
|
| 81 |
+
## License
|
| 82 |
+
|
| 83 |
+
This repository is released under the Apache-2.0 license.
|
| 84 |
+
|
| 85 |
+
```
|
| 86 |
+
```
|