Views
No views yet
pip install diffusers transformers accelerate scipy safetensors1import torch
2from diffusers import StableDiffusionInpaintPipeline
3from diffusers.utils import load_image
4
5model_id = "lcybuaa/Text2Earth-inpainting"
6pipe = StableDiffusionInpaintPipeline.from_pretrained(
7 model_id, torch_dtype=torch.float16,
8 custom_pipeline='pipeline_text2earth_diffusion_inpaint',
9 safety_checker=None
10 )
11pipe.to("cuda")
12
13# load base and mask image
14# image and mask_image should be PIL images.
15# The mask structure is white for inpainting and black for keeping as is
16init_image = load_image(r"https://github.com/Chen-Yang-Liu/Text2Earth/blob/main/images/sparse_residential_310.jpg")
17mask_image = load_image(r"https://github.com/Chen-Yang-Liu/Text2Earth/blob/main/images/sparse_residential_310.png")
18
19prompt = "There is one big green lake"
20image = pipe(prompt=prompt,
21 image=init_image,
22 mask_image=mask_image,
23 height=256,
24 width=256,
25 num_inference_steps=50,
26 guidance_scale=4.0).images[0]
27image.save("lake.png")@ARTICLE{10988859,
author={Liu, Chenyang and Chen, Keyan and Zhao, Rui and Zou, Zhengxia and Shi, Zhenwei},
journal={IEEE Geoscience and Remote Sensing Magazine},
title={Text2Earth: Unlocking text-driven remote sensing image generation with a global-scale dataset and a foundation model},
year={2025},
volume={},
number={},
pages={2-23},
doi={10.1109/MGRS.2025.3560455}}