Segments sky, hopefully mostly correctly.
The model is pretty conservative, so you might want to use something else if you really dont want sky (see examples below).
Basically just pixel-wise robust single model linear regression based on an initial coarse skymask.
NOTE: Does not deal with clouds yet.
Install dependencies using uv (or your preferred package manager):
uv syncOr install manually:
pip install tqdm onnxruntime numpy torch imageio requests opencv-pythonfrom skyseg import load_skyseg_model, segment_sky_mask
from pathlib import Path
# Load the model (downloads automatically if not found)
model = load_skyseg_model()
# Segment sky in an image
image_path = Path("path/to/your/image.jpg")
mask = segment_sky_mask(image_path, model)
# Save the mask
import imageio.v2 as imageio
imageio.imwrite("sky_mask.png", mask)Run the test script to process all images in the assets/ directory:
python tests/test_segmentation.pyThis will generate sky masks and overlay visualizations in tests/outputs/.
Here are some example results from the test suite:
Input: assets/981256188_8f690e95b1_o.jpg.jpg
![]() Input |
![]() Sky Mask |
![]() Overlay |
The overlay shows the original image with non-sky regions highlighted in red.
Input: assets/525678483_c9b1a3665a_o.jpg.jpg
![]() Input |
![]() Sky Mask |
![]() Overlay |
Input: assets/331810308_2fe422b1ec_o.jpg.jpg
![]() Input |
![]() Sky Mask |
![]() Overlay |
Input: assets/264489593_6de914a0ab_o.jpg.jpg
![]() Input |
![]() Sky Mask |
![]() Overlay |
![]() Input |
![]() Sky Mask |
![]() Overlay |
The segmentation mask uses the format:
- 0 = Sky region (black in visualization)
- 255 = Non-sky region (white in visualization)
The model is based on the work from Sky-Segmentation-and-Post-processing and is automatically downloaded from Hugging Face if not found locally.
See the original model repository for license information.
Just link to this Github page if you use this for something :)














