Image-to-Image
Diffusers
TensorBoard
Safetensors
RSEditDiTPipeline
remote-sensing
image-editing
diffusion
Instructions to use BiliSakura/RSEdit-DiT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use BiliSakura/RSEdit-DiT with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline from diffusers.utils import load_image # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("BiliSakura/RSEdit-DiT", dtype=torch.bfloat16, device_map="cuda") prompt = "Turn this cat into a dog" input_image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cat.png") image = pipe(image=input_image, prompt=prompt).images[0] - Notebooks
- Google Colab
- Kaggle
Update README.md and *.py files for RSEdit-DiT
Browse files
README.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# RSEdit-DiT - Inference Guide
|
| 2 |
+
|
| 3 |
+
Quick guide for running inference with RSEdit DiT model for remote sensing image editing.
|
| 4 |
+
|
| 5 |
+
## Quick Start
|
| 6 |
+
|
| 7 |
+
### Python Code Example
|
| 8 |
+
|
| 9 |
+
```python
|
| 10 |
+
import torch
|
| 11 |
+
from PIL import Image
|
| 12 |
+
from diffusers import DiffusionPipeline
|
| 13 |
+
|
| 14 |
+
# Load model with custom pipeline
|
| 15 |
+
model_path = "/data/models/ours/BiliSakura/RSEdit-DiT"
|
| 16 |
+
pipe = DiffusionPipeline.from_pretrained(
|
| 17 |
+
model_path,
|
| 18 |
+
torch_dtype=torch.bfloat16,
|
| 19 |
+
custom_pipeline="pipeline_rsedit_dit"
|
| 20 |
+
).to("cuda")
|
| 21 |
+
|
| 22 |
+
# Switch to AttnProcessor (required for RSEdit DiT)
|
| 23 |
+
from diffusers.models.attention_processor import AttnProcessor
|
| 24 |
+
pipe.transformer.set_attn_processor(AttnProcessor())
|
| 25 |
+
|
| 26 |
+
# Load source image
|
| 27 |
+
source_image = Image.open("satellite_image.png").convert("RGB")
|
| 28 |
+
|
| 29 |
+
# Edit with instruction
|
| 30 |
+
prompt = "Flood the coastal area"
|
| 31 |
+
edited_image = pipe(
|
| 32 |
+
prompt=prompt,
|
| 33 |
+
source_image=source_image,
|
| 34 |
+
num_inference_steps=50,
|
| 35 |
+
guidance_scale=4.5,
|
| 36 |
+
image_guidance_scale=1.5,
|
| 37 |
+
height=512,
|
| 38 |
+
width=512,
|
| 39 |
+
).images[0]
|
| 40 |
+
|
| 41 |
+
# Save result
|
| 42 |
+
edited_image.save("edited_image.png")
|
| 43 |
+
```
|