Skip to content

SatelliteShorelines/SatelliteInPaint

Repository files navigation

📦 SatelliteInPaint

Inpaint satellite imagery using Stable Diffusion. It takes an input image, and fills in the zeros. It does this by dilating and filtering a mask of the zeros in the input image using morphological operators, then using the Stable Diffusion model to carry out inpainting in that region. The original and inpainted images are merged such that only the previously zero pixels are modified.

L9_orig_inpaint_cropped L8_orig_inpaint_cropped

It uses a cuda-enabled GPU and runs using pytorch

User variables:

  • prop_black_upper to set an upper limit on the allowable proportion of black pixels, e.g. 0.3 for 30% black pixels. This tool is not suitable for imagery with very large gaps.
  • size_disk size of dilation applied to mask
  • num_inference_stepsnumber of inference steps (larger = longer time, more accurate)
  • guidance_scale guidance scale
  • method method 1 only replaces missing pixels. method 2 replaces all pixels
  • option option 1 uses the "runwayml/stable-diffusion-inpainting" model, whereas option 2 uses the "stabilityai/stable-diffusion-2-inpainting" pretrained checkpoint
  • num_images_per_prompt number of images over which to average

✍️ Authors

⬇️ Installation

Optionally, install a conda env for your dependencies

conda create -n inpaint python -y
conda activate inpaint

Install the requirements using pip:

pip install -r requirements.txt

Usage

python SatelliteInPaint.py  

Example outputs

2006-12-09-15-22-08_RGB_L5_workflow 2006-12-24-15-23-53_RGB_L7_workflow 2018-08-31-15-43-33_RGB_S2_workflow 2018-07-22-15-47-20_RGB_S2_workflow

About

Inpaint satellite imagery using Stable Diffusion

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages