Add your description here
Project description
slicksmith-ttom
Processing tools for Sentinel-1 SAR Oil spill image dataset for train, validate, and test deep learning models.
This is code for processing and working with a a three part dataset that can be found here:
- Trujillo-Acatitla, R., Tuxpan-Vargas, J., Ovando-Vázquez, C., & Monterrubio-Martínez, E. (2024). Sentinel-1 SAR Oil spill image dataset for train, validate, and test deep learning models. Part I. [Data set]. Zenodo. https://doi.org/10.5281/zenodo.8346860
- Trujillo-Acatitla, R., Tuxpan-Vargas, J., Ovando-Vázquez, C., & Monterrubio-Martínez, E. (2024). Sentinel-1 SAR Oil spill image dataset for train, validate, and test deep learning models. Part II. [Data set]. Zenodo. https://doi.org/10.5281/zenodo.8253899
- Trujillo-Acatitla, R., Tuxpan-Vargas, J., Ovando-Vázquez, C., & Monterrubio-Martínez, E. (2024). Sentinel-1 SAR Oil spill image dataset for train, validate, and test deep learning models. Part III (Version 2024) [Data set]. Zenodo. https://doi.org/10.5281/zenodo.13761290
Getting started
- git clone
uv syncinside repo root folder.- For download, unzip and processing options, run:
uv run python -c "from slicksmith_ttom import main; main()" --help
Remove the --help-flag when you are ready to run things. You will need to specify the path to the destination folder for the download (download_dst), the destination folder for the torchgeo friendly processed data (georef_and_timestamped_dst) and a folder for the info plots and figures to go (figures_dir). There are optional flags to opt out of any of the three steps as well.
eg. if you only want to download and unzip, run:
uv run python -c "from slicksmith_ttom import main; main()" --process_for_torchgeo=0 --make_info_plots=0
- Assuming you have the processed date, the following components are good starting points to work with the data:
from slicksmith_ttom import (
TtomDataModule, ## Lightning data module with methods train_dataloader(), etc. Uses custom BalancedRandomGeoSampler
TtomImageDataset, ## subclass of torchgeo.datasets.RasterDataset for images only
TtomLabelDataset, ## subclass of torchgeo.datasets.RasterDataset for labels only (used with IntersectionDataset in TtomDataModule),
BalancedRandomGeoSampler,
build_integral_mask_from_raster_dataset, ## to make course lookup map for faster sampling.
)
from pathlib import Path
from torch.utils.data import DataLoader
from torchgeo.datasets import IntersectionDataset, concat_samples, stack_samples
from torchgeo.samplers import GridGeoSampler
img_data_path = Path("<your-data-root-path>/Oil_timestamped")
lbl_data_path = Path("<your-data-root-path>/Mask_oil_georef_timestamped")
img_ds = TtomImageDataset(img_dir)
lbl_ds = TtomLabelDataset(lbl_dir)
ds = IntersectionDataset(
dataset1=img_ds,
dataset2=lbl_ds,
collate_fn=concat_samples,
)
## To go through the whole dataset of all images sequentially in a grid-pattern
samp = GridGeoSampler(ds, (512, 512), (512, 512))
## Uncomment below to use the cooler sampler
## integral_mask and integral_transform are optional in BalancedRandomGeoSampler.
## If not provided, takes less memory, but is much slower.
# integral_mask, integral_transform = build_integral_mask_from_raster_dataset(
# lbl_ds
# )
# samp = BalancedRandomGeoSampler(
# ds,
# size=256,
# pos_ratio=0.5,
# integral_mask=integral_mask,
# integral_transform=integral_transform,
# )
dl = DataLoader(
ds,
sampler=samp,
batch_size=16,
collate_fn=stack_samples,
)
for i, sample in enumerate(dl):
img = sample["image"]
mask = sample["mask"]
print(img.shape)
print(mask.shape)
break
The name: slicksmith-ttom: "slick": oil spill slicks, "smith": tools, "ttom": dataset author names' first characters
References
Private overleaf doc with some details for me to remember: https://www.overleaf.com/project/6812010057715ba1a6d19142
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file slicksmith_ttom-0.1.0-py3-none-any.whl.
File metadata
- Download URL: slicksmith_ttom-0.1.0-py3-none-any.whl
- Upload date:
- Size: 18.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
05197ccda7e25bd276b7561b49ce1cb712807b1a9e2013c7202a033baee7f762
|
|
| MD5 |
3a6b15e5d60a428f8c0e00c9c8b7ad89
|
|
| BLAKE2b-256 |
ff468167ec31ec4ac16792cbd366e17f2eedc58f7f89061f5896d89c7ddb17f5
|