geoai-py 0.5.6__py2.py3-none-any.whl → 0.7.0__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- geoai/__init__.py +1 -1
- geoai/classify.py +23 -24
- geoai/extract.py +1 -1
- geoai/geoai.py +10 -4
- geoai/sam.py +832 -0
- geoai/train.py +1041 -9
- geoai/utils.py +342 -0
- {geoai_py-0.5.6.dist-info → geoai_py-0.7.0.dist-info}/METADATA +2 -1
- geoai_py-0.7.0.dist-info/RECORD +17 -0
- {geoai_py-0.5.6.dist-info → geoai_py-0.7.0.dist-info}/WHEEL +1 -1
- geoai_py-0.5.6.dist-info/RECORD +0 -16
- {geoai_py-0.5.6.dist-info → geoai_py-0.7.0.dist-info}/entry_points.txt +0 -0
- {geoai_py-0.5.6.dist-info → geoai_py-0.7.0.dist-info}/licenses/LICENSE +0 -0
- {geoai_py-0.5.6.dist-info → geoai_py-0.7.0.dist-info}/top_level.txt +0 -0
geoai/__init__.py
CHANGED
geoai/classify.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"""The module for training semantic segmentation models for classifying remote sensing imagery."""
|
|
2
2
|
|
|
3
3
|
import os
|
|
4
|
+
|
|
4
5
|
import numpy as np
|
|
5
6
|
|
|
6
7
|
|
|
@@ -110,23 +111,24 @@ def train_classifier(
|
|
|
110
111
|
Returns:
|
|
111
112
|
object: Trained SemanticSegmentationTask model.
|
|
112
113
|
"""
|
|
114
|
+
import multiprocessing as mp
|
|
115
|
+
import timeit
|
|
116
|
+
|
|
117
|
+
import albumentations as A
|
|
113
118
|
import lightning.pytorch as pl
|
|
119
|
+
import torch
|
|
120
|
+
from lightning.pytorch.callbacks import ModelCheckpoint
|
|
121
|
+
from lightning.pytorch.loggers import CSVLogger
|
|
114
122
|
from torch.utils.data import DataLoader
|
|
115
|
-
from torchgeo.
|
|
123
|
+
from torchgeo.datamodules import GeoDataModule
|
|
124
|
+
from torchgeo.datasets import RasterDataset, stack_samples
|
|
116
125
|
from torchgeo.datasets.splits import random_bbox_assignment
|
|
117
126
|
from torchgeo.samplers import (
|
|
118
|
-
RandomGeoSampler,
|
|
119
|
-
RandomBatchGeoSampler,
|
|
120
127
|
GridGeoSampler,
|
|
128
|
+
RandomBatchGeoSampler,
|
|
129
|
+
RandomGeoSampler,
|
|
121
130
|
)
|
|
122
|
-
import torch
|
|
123
|
-
import multiprocessing as mp
|
|
124
|
-
import timeit
|
|
125
|
-
import albumentations as A
|
|
126
|
-
from torchgeo.datamodules import GeoDataModule
|
|
127
131
|
from torchgeo.trainers import SemanticSegmentationTask
|
|
128
|
-
from lightning.pytorch.callbacks import ModelCheckpoint
|
|
129
|
-
from lightning.pytorch.loggers import CSVLogger
|
|
130
132
|
|
|
131
133
|
# Create a wrapper class for albumentations to work with TorchGeo format
|
|
132
134
|
class AlbumentationsWrapper:
|
|
@@ -376,21 +378,19 @@ def _classify_image(
|
|
|
376
378
|
Returns:
|
|
377
379
|
str: Path to the saved classified image.
|
|
378
380
|
"""
|
|
379
|
-
import numpy as np
|
|
380
381
|
import timeit
|
|
381
|
-
from tqdm import tqdm
|
|
382
382
|
|
|
383
|
+
import numpy as np
|
|
384
|
+
import rasterio
|
|
383
385
|
import torch
|
|
386
|
+
from rasterio.io import MemoryFile
|
|
387
|
+
from rasterio.merge import merge
|
|
388
|
+
from rasterio.transform import from_origin
|
|
384
389
|
from torch.utils.data import DataLoader
|
|
385
|
-
|
|
386
390
|
from torchgeo.datasets import RasterDataset, stack_samples
|
|
387
391
|
from torchgeo.samplers import GridGeoSampler
|
|
388
392
|
from torchgeo.trainers import SemanticSegmentationTask
|
|
389
|
-
|
|
390
|
-
import rasterio
|
|
391
|
-
from rasterio.transform import from_origin
|
|
392
|
-
from rasterio.io import MemoryFile
|
|
393
|
-
from rasterio.merge import merge
|
|
393
|
+
from tqdm import tqdm
|
|
394
394
|
|
|
395
395
|
# Set default output path if not provided
|
|
396
396
|
if output_path is None:
|
|
@@ -619,14 +619,12 @@ def classify_image(
|
|
|
619
619
|
str: Path to the saved classified image.
|
|
620
620
|
"""
|
|
621
621
|
import timeit
|
|
622
|
-
|
|
623
|
-
import torch
|
|
624
|
-
from torchgeo.trainers import SemanticSegmentationTask
|
|
622
|
+
import warnings
|
|
625
623
|
|
|
626
624
|
import rasterio
|
|
627
|
-
|
|
628
|
-
import warnings
|
|
625
|
+
import torch
|
|
629
626
|
from rasterio.errors import NotGeoreferencedWarning
|
|
627
|
+
from torchgeo.trainers import SemanticSegmentationTask
|
|
630
628
|
|
|
631
629
|
# Disable specific GDAL/rasterio warnings
|
|
632
630
|
warnings.filterwarnings("ignore", category=UserWarning, module="rasterio._.*")
|
|
@@ -863,9 +861,10 @@ def classify_images(
|
|
|
863
861
|
list: List of paths to the saved classified images.
|
|
864
862
|
"""
|
|
865
863
|
# Import required libraries
|
|
866
|
-
from tqdm import tqdm
|
|
867
864
|
import glob
|
|
868
865
|
|
|
866
|
+
from tqdm import tqdm
|
|
867
|
+
|
|
869
868
|
# Process directory input
|
|
870
869
|
if isinstance(image_paths, str) and os.path.isdir(image_paths):
|
|
871
870
|
# Set default output directory if not provided
|
geoai/extract.py
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Standard Library
|
|
4
4
|
import os
|
|
5
|
+
import time
|
|
5
6
|
|
|
6
7
|
# Third-Party Libraries
|
|
7
8
|
import cv2
|
|
@@ -19,7 +20,6 @@ from torchvision.models.detection import (
|
|
|
19
20
|
maskrcnn_resnet50_fpn,
|
|
20
21
|
)
|
|
21
22
|
from tqdm import tqdm
|
|
22
|
-
import time
|
|
23
23
|
|
|
24
24
|
# Local Imports
|
|
25
25
|
from .utils import get_raster_stats
|
geoai/geoai.py
CHANGED
|
@@ -7,25 +7,31 @@ logging.getLogger("maplibre").setLevel(logging.ERROR)
|
|
|
7
7
|
import leafmap
|
|
8
8
|
import leafmap.maplibregl as maplibregl
|
|
9
9
|
|
|
10
|
+
from .classify import classify_image, classify_images, train_classifier
|
|
10
11
|
from .download import (
|
|
11
12
|
download_naip,
|
|
12
13
|
download_overture_buildings,
|
|
13
14
|
download_pc_stac_item,
|
|
14
|
-
get_overture_data,
|
|
15
15
|
extract_building_stats,
|
|
16
|
+
get_overture_data,
|
|
16
17
|
pc_collection_list,
|
|
17
18
|
pc_item_asset_list,
|
|
18
|
-
pc_stac_search,
|
|
19
19
|
pc_stac_download,
|
|
20
|
+
pc_stac_search,
|
|
20
21
|
read_pc_item_asset,
|
|
21
22
|
view_pc_item,
|
|
22
23
|
view_pc_items,
|
|
23
24
|
)
|
|
24
|
-
from .classify import train_classifier, classify_image, classify_images
|
|
25
25
|
from .extract import *
|
|
26
26
|
from .hf import *
|
|
27
27
|
from .segment import *
|
|
28
|
-
from .train import
|
|
28
|
+
from .train import (
|
|
29
|
+
object_detection,
|
|
30
|
+
object_detection_batch,
|
|
31
|
+
train_MaskRCNN_model,
|
|
32
|
+
train_segmentation_model,
|
|
33
|
+
semantic_segmentation,
|
|
34
|
+
)
|
|
29
35
|
from .utils import *
|
|
30
36
|
|
|
31
37
|
|