Skip to main content

A library for efficient indexing & similarity search of satellite images.

Project description

Earth Search

A library for efficient indexing & similarity search of satellite images.

Earth Search is built on top of Faiss (Facebook AI Similarity Search) with a number of feature extractors for indexing and querying satellite image embeddings.

Installation:

pip install earthsearch

Supported Features:

Images for chipping:

  • Any geospatial image format, e.g., TIF, NITF, etc.

Images for indexing:

  • Any image format, e.g., TIF, PNG, JPEG, etc.
  • If you have a directory of chips, you can index them

Models:

  • ResNet-18: resnet18
  • ResNet-34: resnet34
  • ResNet-50: resnet50
  • ResNet-101: resnet101
  • ResNet-152: resnet152
  • DINOv2 ViT-S/14 distilled: dinov2_vits14
  • DINOv2 ViT-S/14 distilled with Registers: dinov2_vits14_reg
  • DINOv2 ViT-B/14 distilled: dinov2_vitb14
  • DINOv2 ViT-B/14 distilled with Registers: dinov2_vitb14_reg
  • DINOv2 ViT-L/14 distilled: dinov2_vitl14
  • DINOv2 ViT-L/14 distilled with Registers: dinov2_vitl14_reg
  • DINOv2 ViT-g/14: dinov2_vitg14
  • DINOv2 ViT-g/14 with Registers: dinov2_vitg14_reg

Faiss Indices:

  • L2

Planned Features:

Models/Algorithms:

  • SIFT (Scale-Invariant Feature Transform)
  • ORB (Oriented FAST and Rotated BRIEF)
  • Hashing algorithms

Faiss Indices:

  • IndexIVFFlat
  • IndexHNSWFlat
  • IndexLSH
  • IndexBinaryFlat
  • IndexBinaryIVF

Usage:

chip takes a directory of satellite imagery scenes and creates a directory of chips for indexing. If you already have a directory of chips, you can skip this step and run index and search.

Package import usage:

from earthsearch.chip import chip
from earthsearch.index import index
from earthsearch.search import search
from earthsearch.core import show_search_results

image_dir = "directory/path/to/satellite/image/scenes"
chip_dir = "directory/path/to/write/image/chips"
window_size = 512
stride = 0.0
valid_exts = ["tif"]

index_path = "path/to/save/index/to.bin"
indexed_images_path = "path/to/write/indexed/image/paths/to.txt"
index_type = "L2"
model_type = "dinov2_vits14_reg"
device = "cuda" # or "mps", "cpu
batch_size = 32

query_image = "path/to/query/for/top_k/similar/images", 
top_k = 10

chip(image_dir, chip_dir, window_size, stride, valid_exts, multiprocess=True)
index(chip_dir, index_path, indexed_images_path, index_type, model_type, device, batch_size, overwrite_index=False)
results = search(query_image, index_path, indexed_images_path, index_type, top_k, model_type, device)

for idx, result in enumerate(results):
    print(f"{idx + 1}: {result["path"]} - Distance: {result["distance"]}")
show_search_results(query_image, results, max_display=top_k)

CLI usage: earthsearch {chip,index,search} ...

usage: earthsearch chip [-h] --image_dir IMAGE_DIR --chip_dir CHIP_DIR
                        [--window_size WINDOW_SIZE] [--stride STRIDE]
                        [--valid_exts [VALID_EXTS ...]] [--multiprocess]

options:
  -h, --help            show this help message and exit
  --image_dir IMAGE_DIR
                        Directory path to images
  --chip_dir CHIP_DIR   Directory path to write chips to
  --window_size WINDOW_SIZE
                        Size of sliding window, e.g., 512
  --stride STRIDE       Amount of overlap in x, y direction, e.g., 0.2
  --valid_exts [VALID_EXTS ...]
                        Image extensions to filter for
  --multiprocess        Use multiprocessing vs multithreading
usage: earthsearch index [-h] --image_dir IMAGE_DIR --index_path INDEX_PATH
                         --indexed_images_path INDEXED_IMAGES_PATH --index_type INDEX_TYPE
                         --model_type MODEL_TYPE [--device DEVICE] [--batch_size BATCH_SIZE]
                         [--overwrite_index]

options:
  -h, --help            show this help message and exit
  --image_dir IMAGE_DIR
                        Path to directory of images to index
  --index_path INDEX_PATH
                        Path to save index
  --indexed_images_path INDEXED_IMAGES_PATH
                        Path to save file containing indexed image paths
  --index_type INDEX_TYPE
                        Type of index to use (currently only using L2)
  --model_type MODEL_TYPE
                        Type of model to use
  --device DEVICE       Device to use for feature extraction (cuda, mps, cpu)
  --batch_size BATCH_SIZE
                        Number of images per batch
  --overwrite_index     Overwrite existing index of same index_path
(.venv)  ✝  ~/repos/earthsearch   main 
usage: earthsearch search [-h] --query_image QUERY_IMAGE --index_path INDEX_PATH
                          --indexed_images_path INDEXED_IMAGES_PATH --index_type INDEX_TYPE
                          --top_k TOP_K --model_type MODEL_TYPE [--device DEVICE]

options:
  -h, --help            show this help message and exit
  --query_image QUERY_IMAGE
                        Path to directory of images to index
  --index_path INDEX_PATH
                        Path to saved index
  --indexed_images_path INDEXED_IMAGES_PATH
                        Path to file containing indexed image paths
  --index_type INDEX_TYPE
                        Type of index to use (currently only using L2)
  --top_k TOP_K         top k-Nearest Neighbors to return
  --model_type MODEL_TYPE
                        Type of model to use
  --device DEVICE       Device to use for feature extraction (cuda, mps, cpu)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

earthsearch-0.1.2.tar.gz (12.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

earthsearch-0.1.2-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

Details for the file earthsearch-0.1.2.tar.gz.

File metadata

  • Download URL: earthsearch-0.1.2.tar.gz
  • Upload date:
  • Size: 12.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for earthsearch-0.1.2.tar.gz
Algorithm Hash digest
SHA256 07cecc0c21bc567849cf085414794b96302055520d2d88d7dca593e3006c4e18
MD5 39317242008511719e9d6fbe78f82b98
BLAKE2b-256 d59dc565c5188b132b19d9d9718b3cc4a87d9f79f8e0cb6394c2c4d0d2c33197

See more details on using hashes here.

File details

Details for the file earthsearch-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: earthsearch-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 13.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for earthsearch-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a2e1a774fd221129373b08f0042879113eee8b4cd57f73e7ebfabd9b8c8d39fe
MD5 bc26cf9b7a1326d3ab3f43a20c1d7ae5
BLAKE2b-256 c6e3e83c0a239d1bbc5cfe4a3444b3a5f28290a6d0d646152417ac1961b77e5d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page