<div align="center">
<p>
<a align="center" href="" target="_blank">
<img
width="850"
src="https://media.roboflow.com/open-source/autodistill/autodistill-banner.png"
>
</a>
</p>
</div>
# Autodistill HLS Geospatial Module
This repository contains the code supporting the HLS Geospatial base model for use with [Autodistill](https://github.com/autodistill/autodistill).
[Harmonized Landsat and Sentinel-2 (HLS) Prithvi](https://github.com/NASA-IMPACT/hls-foundation-os) is a collection of foundation models for geospatial analysis, developed by NASA and IBM. You can use Autodistill to automatically label images for use in training segmentation models.
The following models are supported:
- [Prithvi-100M-sen1floods11](https://huggingface.co/ibm-nasa-geospatial/Prithvi-100M-sen1floods11)
This module accepts `tiff` files as input and returns segmentation masks.
Read the full [Autodistill documentation](https://autodistill.github.io/autodistill/).
Read the [HLS Geospatial Autodistill documentation](https://autodistill.github.io/autodistill/base_models/clip/).
## Installation
To use HLS Geospatial with autodistill, you need to install the following dependency:
```bash
pip3 install autodistill-hls-geospatial
```
## Quickstart
```python
from autodistill_hls_geospatial import HLSGeospatial
import numpy as np
import rasterio
from skimage import exposure
import supervision as sv
from autodistill_hls_geospatial import HLSGeospatial
def stretch_rgb(rgb):
ls_pct = 1
pLow, pHigh = np.percentile(rgb[~np.isnan(rgb)], (ls_pct, 100 - ls_pct))
img_rescale = exposure.rescale_intensity(rgb, in_range=(pLow, pHigh))
return img_rescale
#replace with the name of the file you want to label
FILE_NAME = "USA_430764_S2Hand.tif"
with rasterio.open(FILE_NAME) as src:
image = src.read()
mask = image
rgb = stretch_rgb(
(mask[[3, 2, 1], :, :].transpose((1, 2, 0)) / 10000 * 255).astype(np.uint8)
)
base_model = HLSGeospatial()
# replace with the file you want to use
detections = base_model.predict(FILE_NAME)
mask_annotator = sv.MaskAnnotator()
annotated_image = mask_annotator.annotate(scene=rgb, detections=detections)
sv.plot_image(annotated_image, size=(10, 10))
# label a folder of .tif files
base_model.label("./context_images", extension=".tif")
```
## License
This project is licensed under an [Apache 2.0 license](LICENSE).
## 🏆 Contributing
We love your input! Please see the core Autodistill [contributing guide](https://github.com/autodistill/autodistill/blob/main/CONTRIBUTING.md) to get started. Thank you 🙏 to all our contributors!
Raw data
{
"_id": null,
"home_page": "https://github.com/autodistill/autodistill-hls-geospatial",
"name": "autodistill-hls-geospatial",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "",
"keywords": "",
"author": "Roboflow",
"author_email": "support@roboflow.com",
"download_url": "https://files.pythonhosted.org/packages/cf/a6/92c059faa714bd45c3534a54a653b6157330b2ec1d31d2bb950ddccc410b/autodistill-hls-geospatial-0.1.0.tar.gz",
"platform": null,
"description": "<div align=\"center\">\n <p>\n <a align=\"center\" href=\"\" target=\"_blank\">\n <img\n width=\"850\"\n src=\"https://media.roboflow.com/open-source/autodistill/autodistill-banner.png\"\n >\n </a>\n </p>\n</div>\n\n# Autodistill HLS Geospatial Module\n\nThis repository contains the code supporting the HLS Geospatial base model for use with [Autodistill](https://github.com/autodistill/autodistill).\n\n[Harmonized Landsat and Sentinel-2 (HLS) Prithvi](https://github.com/NASA-IMPACT/hls-foundation-os) is a collection of foundation models for geospatial analysis, developed by NASA and IBM. You can use Autodistill to automatically label images for use in training segmentation models.\n\nThe following models are supported:\n\n- [Prithvi-100M-sen1floods11](https://huggingface.co/ibm-nasa-geospatial/Prithvi-100M-sen1floods11)\n\nThis module accepts `tiff` files as input and returns segmentation masks.\n\nRead the full [Autodistill documentation](https://autodistill.github.io/autodistill/).\n\nRead the [HLS Geospatial Autodistill documentation](https://autodistill.github.io/autodistill/base_models/clip/).\n\n## Installation\n\nTo use HLS Geospatial with autodistill, you need to install the following dependency:\n\n```bash\npip3 install autodistill-hls-geospatial\n```\n\n## Quickstart\n\n```python\nfrom autodistill_hls_geospatial import HLSGeospatial\nimport numpy as np\nimport rasterio\nfrom skimage import exposure\nimport supervision as sv\n\nfrom autodistill_hls_geospatial import HLSGeospatial\n\ndef stretch_rgb(rgb):\n ls_pct = 1\n pLow, pHigh = np.percentile(rgb[~np.isnan(rgb)], (ls_pct, 100 - ls_pct))\n img_rescale = exposure.rescale_intensity(rgb, in_range=(pLow, pHigh))\n\n return img_rescale\n\n\n#replace with the name of the file you want to label\nFILE_NAME = \"USA_430764_S2Hand.tif\"\n\nwith rasterio.open(FILE_NAME) as src:\n image = src.read()\n\n mask = image\n\n rgb = stretch_rgb(\n (mask[[3, 2, 1], :, :].transpose((1, 2, 0)) / 10000 * 255).astype(np.uint8)\n )\n\n base_model = HLSGeospatial()\n\n # replace with the file you want to use\n detections = base_model.predict(FILE_NAME)\n\n mask_annotator = sv.MaskAnnotator()\n\n annotated_image = mask_annotator.annotate(scene=rgb, detections=detections)\n\n sv.plot_image(annotated_image, size=(10, 10))\n\n# label a folder of .tif files\nbase_model.label(\"./context_images\", extension=\".tif\")\n```\n\n\n## License\n\nThis project is licensed under an [Apache 2.0 license](LICENSE).\n\n## \ud83c\udfc6 Contributing\n\nWe love your input! Please see the core Autodistill [contributing guide](https://github.com/autodistill/autodistill/blob/main/CONTRIBUTING.md) to get started. Thank you \ud83d\ude4f to all our contributors!\n",
"bugtrack_url": null,
"license": "",
"summary": "Use the HLS Geospatial model made by NASA and IBM to generate masks for use in training a fine-tuned segmentation model.",
"version": "0.1.0",
"project_urls": {
"Homepage": "https://github.com/autodistill/autodistill-hls-geospatial"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "2b98bb62feb491f157f41d47dee3935bee4122d36e49dbaf21d6186d9dd79db3",
"md5": "e25c94b2e5fae04561e1db538d8b747f",
"sha256": "29aae0b63f6dbb5e48b155674f329c368caa31f7e9937824f31d90a670bcdd33"
},
"downloads": -1,
"filename": "autodistill_hls_geospatial-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e25c94b2e5fae04561e1db538d8b747f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 10270,
"upload_time": "2023-11-13T21:26:56",
"upload_time_iso_8601": "2023-11-13T21:26:56.934104Z",
"url": "https://files.pythonhosted.org/packages/2b/98/bb62feb491f157f41d47dee3935bee4122d36e49dbaf21d6186d9dd79db3/autodistill_hls_geospatial-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "cfa692c059faa714bd45c3534a54a653b6157330b2ec1d31d2bb950ddccc410b",
"md5": "88d81713dd2179766ce776f622edff87",
"sha256": "5635cb091156bd3f1787aabb091be113006fb6c37ce567f90522d3b886da1e58"
},
"downloads": -1,
"filename": "autodistill-hls-geospatial-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "88d81713dd2179766ce776f622edff87",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 9515,
"upload_time": "2023-11-13T21:26:58",
"upload_time_iso_8601": "2023-11-13T21:26:58.559533Z",
"url": "https://files.pythonhosted.org/packages/cf/a6/92c059faa714bd45c3534a54a653b6157330b2ec1d31d2bb950ddccc410b/autodistill-hls-geospatial-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-11-13 21:26:58",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "autodistill",
"github_project": "autodistill-hls-geospatial",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "autodistill-hls-geospatial"
}