Instructions to use BiliSakura/Text2Earth-ControlNet-xBD with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use BiliSakura/Text2Earth-ControlNet-xBD with Diffusers:
pip install -U diffusers transformers accelerate
from diffusers import ControlNetModel, StableDiffusionControlNetPipeline controlnet = ControlNetModel.from_pretrained("BiliSakura/Text2Earth-ControlNet-xBD") pipe = StableDiffusionControlNetPipeline.from_pretrained( "lcybuaa/Text2Earth", controlnet=controlnet ) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Draw Things
- DiffusionBee
Add files using upload-large-folder tool
Browse files- README.md +71 -0
- controlnet/config.json +56 -0
- controlnet/diffusion_pytorch_model.safetensors +3 -0
README.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: cc-by-nc-sa-4.0
|
| 3 |
+
library_name: diffusers
|
| 4 |
+
pipeline_tag: text-to-image
|
| 5 |
+
base_model: lcybuaa/Text2Earth
|
| 6 |
+
tags:
|
| 7 |
+
- controlnet
|
| 8 |
+
- remote-sensing
|
| 9 |
+
- xbd
|
| 10 |
+
- building-damage
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
# Text2Earth ControlNet for xBD
|
| 14 |
+
|
| 15 |
+
ControlNet fine-tuned on [xBD](https://xview2.org/download) post-event imagery. It takes a building-damage mask and samples a matching satellite image from [Text2Earth](https://huggingface.co/lcybuaa/Text2Earth).
|
| 16 |
+
|
| 17 |
+
The ControlNet is the only trained module. Text2Earth (UNet, VAE, text encoder) stays frozen.
|
| 18 |
+
|
| 19 |
+
## Conditioning
|
| 20 |
+
|
| 21 |
+
| Item | Value |
|
| 22 |
+
| --- | --- |
|
| 23 |
+
| Base model | [lcybuaa/Text2Earth](https://huggingface.co/lcybuaa/Text2Earth) |
|
| 24 |
+
| Conditioning | 3-channel binary damage mask, RGB order, values in `{0, 1}` |
|
| 25 |
+
| Prompt | `18_GOOGLE_LEVEL_a high resolution satellite image` |
|
| 26 |
+
| Scheduler | Euler discrete |
|
| 27 |
+
| Steps / guidance | 50 / 1.0 |
|
| 28 |
+
|
| 29 |
+
Binary channels follow the xBD hues: background black, no-damage green, minor blue, major yellow, destroy red, un-classified white.
|
| 30 |
+
|
| 31 |
+
## Usage
|
| 32 |
+
|
| 33 |
+
```python
|
| 34 |
+
import torch
|
| 35 |
+
from diffusers import (
|
| 36 |
+
ControlNetModel,
|
| 37 |
+
EulerDiscreteScheduler,
|
| 38 |
+
StableDiffusionControlNetPipeline,
|
| 39 |
+
)
|
| 40 |
+
from PIL import Image
|
| 41 |
+
|
| 42 |
+
repo = "BiliSakura/Text2Earth-ControlNet-xBD"
|
| 43 |
+
base = "lcybuaa/Text2Earth"
|
| 44 |
+
dtype = torch.float16
|
| 45 |
+
|
| 46 |
+
controlnet = ControlNetModel.from_pretrained(
|
| 47 |
+
repo, subfolder="controlnet", torch_dtype=dtype
|
| 48 |
+
)
|
| 49 |
+
pipe = StableDiffusionControlNetPipeline.from_pretrained(
|
| 50 |
+
base,
|
| 51 |
+
controlnet=controlnet,
|
| 52 |
+
scheduler=EulerDiscreteScheduler.from_pretrained(base, subfolder="scheduler"),
|
| 53 |
+
torch_dtype=dtype,
|
| 54 |
+
safety_checker=None,
|
| 55 |
+
).to("cuda")
|
| 56 |
+
|
| 57 |
+
image = pipe(
|
| 58 |
+
"18_GOOGLE_LEVEL_a high resolution satellite image",
|
| 59 |
+
image=Image.open("mask.png"),
|
| 60 |
+
num_inference_steps=50,
|
| 61 |
+
guidance_scale=1.0,
|
| 62 |
+
controlnet_conditioning_scale=1.0,
|
| 63 |
+
).images[0]
|
| 64 |
+
image.save("post_event.png")
|
| 65 |
+
```
|
| 66 |
+
|
| 67 |
+
Weights are under `controlnet/`.
|
| 68 |
+
|
| 69 |
+
## License
|
| 70 |
+
|
| 71 |
+
[CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/), the license of the xBD dataset these weights were trained on.
|
controlnet/config.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_class_name": "ControlNetModel",
|
| 3 |
+
"_diffusers_version": "0.36.0",
|
| 4 |
+
"act_fn": "silu",
|
| 5 |
+
"addition_embed_type": null,
|
| 6 |
+
"addition_embed_type_num_heads": 64,
|
| 7 |
+
"addition_time_embed_dim": null,
|
| 8 |
+
"attention_head_dim": [
|
| 9 |
+
5,
|
| 10 |
+
10,
|
| 11 |
+
20,
|
| 12 |
+
20
|
| 13 |
+
],
|
| 14 |
+
"block_out_channels": [
|
| 15 |
+
320,
|
| 16 |
+
640,
|
| 17 |
+
1280,
|
| 18 |
+
1280
|
| 19 |
+
],
|
| 20 |
+
"class_embed_type": "timestep",
|
| 21 |
+
"conditioning_channels": 3,
|
| 22 |
+
"conditioning_embedding_out_channels": [
|
| 23 |
+
16,
|
| 24 |
+
32,
|
| 25 |
+
96,
|
| 26 |
+
256
|
| 27 |
+
],
|
| 28 |
+
"controlnet_conditioning_channel_order": "rgb",
|
| 29 |
+
"cross_attention_dim": 1024,
|
| 30 |
+
"down_block_types": [
|
| 31 |
+
"CrossAttnDownBlock2D",
|
| 32 |
+
"CrossAttnDownBlock2D",
|
| 33 |
+
"CrossAttnDownBlock2D",
|
| 34 |
+
"DownBlock2D"
|
| 35 |
+
],
|
| 36 |
+
"downsample_padding": 1,
|
| 37 |
+
"encoder_hid_dim": null,
|
| 38 |
+
"encoder_hid_dim_type": null,
|
| 39 |
+
"flip_sin_to_cos": true,
|
| 40 |
+
"freq_shift": 0,
|
| 41 |
+
"global_pool_conditions": false,
|
| 42 |
+
"in_channels": 4,
|
| 43 |
+
"layers_per_block": 2,
|
| 44 |
+
"mid_block_scale_factor": 1,
|
| 45 |
+
"mid_block_type": "UNetMidBlock2DCrossAttn",
|
| 46 |
+
"norm_eps": 1e-05,
|
| 47 |
+
"norm_num_groups": 32,
|
| 48 |
+
"num_attention_heads": null,
|
| 49 |
+
"num_class_embeds": null,
|
| 50 |
+
"only_cross_attention": false,
|
| 51 |
+
"projection_class_embeddings_input_dim": null,
|
| 52 |
+
"resnet_time_scale_shift": "default",
|
| 53 |
+
"transformer_layers_per_block": 1,
|
| 54 |
+
"upcast_attention": false,
|
| 55 |
+
"use_linear_projection": true
|
| 56 |
+
}
|
controlnet/diffusion_pytorch_model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:38b83e5bbba46432b2aec5c2f9f8cf7d9f7d294159eabf20b711de8509a4bb52
|
| 3 |
+
size 1465156288
|