geo-inference


Namegeo-inference JSON
Version 2.0.1 PyPI version JSON
download
home_pageNone
SummaryExtract features from geospatial imagery using deep learning models
upload_time2024-04-17 02:59:03
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseMIT License Copyright (c) 2023 Victor Alhassan Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords pytorch deep learning machine learning remote sensing satellite imagery earth observation geospatial
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Geo Inference

geo-inference is a Python package designed for feature extraction from geospatial imagery using compatible deep learning models. It provides a convenient way to extract features from large TIFF images and save the output mask as a TIFF file. It also supports converting the output mask to vector format (*file_name.geojson*), YOLO format (*file_name.csv*), and COCO format (*file_name.json*). This package is particularly useful for applications in remote sensing, environmental monitoring, and urban planning.

## Installation

Geo-inference requires Python 3.11. To install the package, use:

```
pip install geo-inference
```

## Usage

**Input:** GeoTiffs with compatible TorchScript model. For example: A pytorch model trained on high resolution geospatial imagery with the following features:

- pixel size (0.1m to 3m)
- data type (uint8)

expects an input image with the same features. An example notebook for how the package is used is provided in this repo. 


*Here's an example of how to use Geo Inference (Command line and Script):*

**Command line**
```bash
python geo_inference.py -a <args>
```
- `-a`, `--args`: Path to arguments stored in yaml, consult ./config/sample_config.yaml
```bash
python geo_inference.py -i <image> -m <model> -wd <work_dir> -bs <batch_size> -v <vec> -d <device> -id <gpu_id>
```
- `-i`, `--image`: Path to Geotiff
- `-bb`, `--bbox`: AOI bbox in this format "minx, miny, maxx, maxy" (Optional)
- `-m`, `--model`: Path or URL to the model file
- `-wd`, `--work_dir`: Working Directory
- `-bs`, `--batch_size`: The Batch Size
- `-v`, `--vec`: Vector Conversion
- `-d`, `--device`: CPU or GPU Device
- `-id`, `--gpu_id`: GPU ID, Default = 0

You can also use the `-h` option to get a list of supported arguments:

```bash
python geo_inference.py -h
```

**Import script**
```python
from geo_inference.geo_inference import GeoInference

# Initialize the GeoInference object
geo_inference = GeoInference(
    model="/path/to/segformer_B5.pt",
    work_dir="/path/to/work/dir",
    batch_size=4,
    mask_to_vec=True,
    device="gpu",
    gpu_id=0
)

# Perform feature extraction on a TIFF image
image_path = "/path/to/image.tif"
patch_size = 512
stride_size = 256
geo_inference(image_path, patch_size, stride_size)
```

## Parameters

The `GeoInference` class takes the following parameters:

- `model`: The path or URL to the model file (.pt for PyTorch models) to use for feature extraction.
- `work_dir`: The path to the working directory. Default is `"~/.cache"`.
- `batch_size`: The batch size to use for feature extraction. Default is `4`.
- `mask_to_vec`: If set to `"True"`, vector files will be created. Default is `"False"`
- `device`: The device to use for feature extraction. Can be `"cpu"` or `"gpu"`. Default is `"gpu"`.
- `gpu_id`: The ID of the GPU to use for feature extraction. Default is `0`.

## Output

The `GeoInference` class outputs the following files:

- `mask.tif`: The output mask file in TIFF format.
- `polygons.geojson`: The output polygon file in GeoJSON format. This file is only generated if the `mask_to_vec` parameter is set to `True`.
- `yolo.csv`: The output YOLO file in CSV format. This file is only generated if the `mask_to_vec` parameter is set to `True`.

Each file contains the extracted features from the input geospatial imagery.

## License

Geo Inference is released under the MIT License. See `LICENSE` for more information.

## Contact

For any questions or concerns, please open an issue on GitHub.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "geo-inference",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "pytorch, deep learning, machine learning, remote sensing, satellite imagery, earth observation, geospatial",
    "author": null,
    "author_email": "Victor Alhassan <victor.alhassan@nrcan-rncan.gc.ca>",
    "download_url": "https://files.pythonhosted.org/packages/89/f0/935acd265d01ad94ffa588e5e5bac3238bada7412033df40db4b7e0cd222/geo_inference-2.0.1.tar.gz",
    "platform": null,
    "description": "# Geo Inference\n\ngeo-inference is a Python package designed for feature extraction from geospatial imagery using compatible deep learning models. It provides a convenient way to extract features from large TIFF images and save the output mask as a TIFF file. It also supports converting the output mask to vector format (*file_name.geojson*), YOLO format (*file_name.csv*), and COCO format (*file_name.json*). This package is particularly useful for applications in remote sensing, environmental monitoring, and urban planning.\n\n## Installation\n\nGeo-inference requires Python 3.11. To install the package, use:\n\n```\npip install geo-inference\n```\n\n## Usage\n\n**Input:** GeoTiffs with compatible TorchScript model. For example: A pytorch model trained on high resolution geospatial imagery with the following features:\n\n- pixel size (0.1m to 3m)\n- data type (uint8)\n\nexpects an input image with the same features. An example notebook for how the package is used is provided in this repo. \n\n\n*Here's an example of how to use Geo Inference (Command line and Script):*\n\n**Command line**\n```bash\npython geo_inference.py -a <args>\n```\n- `-a`, `--args`: Path to arguments stored in yaml, consult ./config/sample_config.yaml\n```bash\npython geo_inference.py -i <image> -m <model> -wd <work_dir> -bs <batch_size> -v <vec> -d <device> -id <gpu_id>\n```\n- `-i`, `--image`: Path to Geotiff\n- `-bb`, `--bbox`: AOI bbox in this format \"minx, miny, maxx, maxy\" (Optional)\n- `-m`, `--model`: Path or URL to the model file\n- `-wd`, `--work_dir`: Working Directory\n- `-bs`, `--batch_size`: The Batch Size\n- `-v`, `--vec`: Vector Conversion\n- `-d`, `--device`: CPU or GPU Device\n- `-id`, `--gpu_id`: GPU ID, Default = 0\n\nYou can also use the `-h` option to get a list of supported arguments:\n\n```bash\npython geo_inference.py -h\n```\n\n**Import script**\n```python\nfrom geo_inference.geo_inference import GeoInference\n\n# Initialize the GeoInference object\ngeo_inference = GeoInference(\n    model=\"/path/to/segformer_B5.pt\",\n    work_dir=\"/path/to/work/dir\",\n    batch_size=4,\n    mask_to_vec=True,\n    device=\"gpu\",\n    gpu_id=0\n)\n\n# Perform feature extraction on a TIFF image\nimage_path = \"/path/to/image.tif\"\npatch_size = 512\nstride_size = 256\ngeo_inference(image_path, patch_size, stride_size)\n```\n\n## Parameters\n\nThe `GeoInference` class takes the following parameters:\n\n- `model`: The path or URL to the model file (.pt for PyTorch models) to use for feature extraction.\n- `work_dir`: The path to the working directory. Default is `\"~/.cache\"`.\n- `batch_size`: The batch size to use for feature extraction. Default is `4`.\n- `mask_to_vec`: If set to `\"True\"`, vector files will be created. Default is `\"False\"`\n- `device`: The device to use for feature extraction. Can be `\"cpu\"` or `\"gpu\"`. Default is `\"gpu\"`.\n- `gpu_id`: The ID of the GPU to use for feature extraction. Default is `0`.\n\n## Output\n\nThe `GeoInference` class outputs the following files:\n\n- `mask.tif`: The output mask file in TIFF format.\n- `polygons.geojson`: The output polygon file in GeoJSON format. This file is only generated if the `mask_to_vec` parameter is set to `True`.\n- `yolo.csv`: The output YOLO file in CSV format. This file is only generated if the `mask_to_vec` parameter is set to `True`.\n\nEach file contains the extracted features from the input geospatial imagery.\n\n## License\n\nGeo Inference is released under the MIT License. See `LICENSE` for more information.\n\n## Contact\n\nFor any questions or concerns, please open an issue on GitHub.\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2023 Victor Alhassan  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "Extract features from geospatial imagery using deep learning models",
    "version": "2.0.1",
    "project_urls": {
        "Homepage": "https://github.com/valhassan/geo-inference"
    },
    "split_keywords": [
        "pytorch",
        " deep learning",
        " machine learning",
        " remote sensing",
        " satellite imagery",
        " earth observation",
        " geospatial"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "68000f5342f06a901858bcec3205f5eab44f9dc169f53251693fc83e8c618746",
                "md5": "ee261e438e2086a34941d9b8b6388031",
                "sha256": "58dad8aba4a8487538c4ba07c582efacdcdc3ea37b5d807e2fb4cbc5862425ce"
            },
            "downloads": -1,
            "filename": "geo_inference-2.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ee261e438e2086a34941d9b8b6388031",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 27827,
            "upload_time": "2024-04-17T02:59:01",
            "upload_time_iso_8601": "2024-04-17T02:59:01.448111Z",
            "url": "https://files.pythonhosted.org/packages/68/00/0f5342f06a901858bcec3205f5eab44f9dc169f53251693fc83e8c618746/geo_inference-2.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "89f0935acd265d01ad94ffa588e5e5bac3238bada7412033df40db4b7e0cd222",
                "md5": "5ab75034b9beffe02463bd61d0b2438a",
                "sha256": "f146677c581e03c041156408d1187ded9ada60d1fff1b35943a7078f355193ee"
            },
            "downloads": -1,
            "filename": "geo_inference-2.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "5ab75034b9beffe02463bd61d0b2438a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 28119,
            "upload_time": "2024-04-17T02:59:03",
            "upload_time_iso_8601": "2024-04-17T02:59:03.173886Z",
            "url": "https://files.pythonhosted.org/packages/89/f0/935acd265d01ad94ffa588e5e5bac3238bada7412033df40db4b7e0cd222/geo_inference-2.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-17 02:59:03",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "valhassan",
    "github_project": "geo-inference",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "geo-inference"
}
        
Elapsed time: 0.23180s