geoai-py 0.26.0__py2.py3-none-any.whl → 0.28.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 +41 -1
- geoai/auto.py +4 -1
- geoai/change_detection.py +1 -1
- geoai/detectron2.py +4 -1
- geoai/extract.py +10 -7
- geoai/hf.py +3 -3
- geoai/moondream.py +2 -2
- geoai/onnx.py +1155 -0
- geoai/prithvi.py +92 -7
- geoai/sam.py +2 -1
- geoai/segment.py +10 -1
- geoai/timm_regress.py +1652 -0
- geoai/train.py +1 -1
- geoai/utils.py +550 -1
- {geoai_py-0.26.0.dist-info → geoai_py-0.28.0.dist-info}/METADATA +9 -7
- {geoai_py-0.26.0.dist-info → geoai_py-0.28.0.dist-info}/RECORD +20 -18
- {geoai_py-0.26.0.dist-info → geoai_py-0.28.0.dist-info}/WHEEL +1 -1
- {geoai_py-0.26.0.dist-info → geoai_py-0.28.0.dist-info}/entry_points.txt +0 -0
- {geoai_py-0.26.0.dist-info → geoai_py-0.28.0.dist-info}/licenses/LICENSE +0 -0
- {geoai_py-0.26.0.dist-info → geoai_py-0.28.0.dist-info}/top_level.txt +0 -0
geoai/__init__.py
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
__author__ = """Qiusheng Wu"""
|
|
4
4
|
__email__ = "giswqs@gmail.com"
|
|
5
|
-
__version__ = "0.
|
|
5
|
+
__version__ = "0.28.0"
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
import os
|
|
@@ -101,6 +101,14 @@ def set_proj_lib_path(verbose=False):
|
|
|
101
101
|
|
|
102
102
|
from .dinov3 import DINOv3GeoProcessor, analyze_image_patches, create_similarity_map
|
|
103
103
|
from .geoai import *
|
|
104
|
+
from .utils import (
|
|
105
|
+
orthogonalize,
|
|
106
|
+
regularization,
|
|
107
|
+
hybrid_regularization,
|
|
108
|
+
adaptive_regularization,
|
|
109
|
+
flipnslide_augmentation,
|
|
110
|
+
export_flipnslide_tiles,
|
|
111
|
+
)
|
|
104
112
|
|
|
105
113
|
from .timm_train import (
|
|
106
114
|
get_timm_model,
|
|
@@ -122,6 +130,25 @@ from .timm_segment import (
|
|
|
122
130
|
push_timm_model_to_hub,
|
|
123
131
|
)
|
|
124
132
|
|
|
133
|
+
from .timm_regress import (
|
|
134
|
+
PixelRegressionModel,
|
|
135
|
+
PixelRegressionDataset,
|
|
136
|
+
create_regression_tiles,
|
|
137
|
+
train_pixel_regressor,
|
|
138
|
+
predict_raster,
|
|
139
|
+
evaluate_regression,
|
|
140
|
+
plot_regression_comparison,
|
|
141
|
+
plot_scatter,
|
|
142
|
+
plot_training_history,
|
|
143
|
+
visualize_prediction,
|
|
144
|
+
plot_regression_results,
|
|
145
|
+
# Backward compatibility aliases
|
|
146
|
+
TimmRegressor,
|
|
147
|
+
RegressionDataset,
|
|
148
|
+
train_timm_regressor,
|
|
149
|
+
create_regression_patches,
|
|
150
|
+
)
|
|
151
|
+
|
|
125
152
|
# Import tools subpackage
|
|
126
153
|
from . import tools
|
|
127
154
|
|
|
@@ -145,6 +172,18 @@ except ImportError:
|
|
|
145
172
|
# super_resolution not available (missing dependency)
|
|
146
173
|
pass
|
|
147
174
|
|
|
175
|
+
# ONNX Runtime support
|
|
176
|
+
try:
|
|
177
|
+
from .onnx import (
|
|
178
|
+
ONNXGeoModel,
|
|
179
|
+
export_to_onnx,
|
|
180
|
+
onnx_semantic_segmentation,
|
|
181
|
+
onnx_image_classification,
|
|
182
|
+
)
|
|
183
|
+
except ImportError:
|
|
184
|
+
# ONNX not available (missing dependency)
|
|
185
|
+
pass
|
|
186
|
+
|
|
148
187
|
# Moondream Vision Language Model
|
|
149
188
|
try:
|
|
150
189
|
from .moondream import (
|
|
@@ -167,6 +206,7 @@ except ImportError:
|
|
|
167
206
|
try:
|
|
168
207
|
from .prithvi import (
|
|
169
208
|
PrithviProcessor,
|
|
209
|
+
get_available_prithvi_models,
|
|
170
210
|
load_prithvi_model,
|
|
171
211
|
prithvi_inference,
|
|
172
212
|
)
|
geoai/auto.py
CHANGED
|
@@ -24,7 +24,6 @@ Example:
|
|
|
24
24
|
import os
|
|
25
25
|
from typing import Any, Dict, List, Optional, Tuple, Union
|
|
26
26
|
|
|
27
|
-
import cv2
|
|
28
27
|
import geopandas as gpd
|
|
29
28
|
import numpy as np
|
|
30
29
|
import rasterio
|
|
@@ -877,6 +876,8 @@ class AutoGeoModel:
|
|
|
877
876
|
**kwargs: Any,
|
|
878
877
|
) -> Dict[str, Any]:
|
|
879
878
|
"""Run tiled inference for large images."""
|
|
879
|
+
import cv2 # Lazy import to avoid QGIS opencv conflicts
|
|
880
|
+
|
|
880
881
|
if data.ndim == 3:
|
|
881
882
|
_, height, width = data.shape
|
|
882
883
|
else:
|
|
@@ -1872,6 +1873,7 @@ def show_segmentation(
|
|
|
1872
1873
|
>>> result = geoai.auto.semantic_segmentation("aerial.tif", output_path="seg.tif")
|
|
1873
1874
|
>>> fig = show_segmentation("aerial.tif", result["mask"])
|
|
1874
1875
|
"""
|
|
1876
|
+
import cv2 # Lazy import to avoid QGIS opencv conflicts
|
|
1875
1877
|
import matplotlib.pyplot as plt
|
|
1876
1878
|
|
|
1877
1879
|
img, _ = _load_image_for_display(source)
|
|
@@ -1941,6 +1943,7 @@ def show_depth(
|
|
|
1941
1943
|
>>> result = geoai.auto.depth_estimation("aerial.tif", output_path="depth.tif")
|
|
1942
1944
|
>>> fig = show_depth("aerial.tif", result["depth"])
|
|
1943
1945
|
"""
|
|
1946
|
+
import cv2 # Lazy import to avoid QGIS opencv conflicts
|
|
1944
1947
|
import matplotlib.pyplot as plt
|
|
1945
1948
|
|
|
1946
1949
|
img, _ = _load_image_for_display(source)
|
geoai/change_detection.py
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import os
|
|
4
4
|
from typing import Any, Dict, List, Optional, Tuple, Union
|
|
5
5
|
|
|
6
|
-
import cv2
|
|
7
6
|
import matplotlib.pyplot as plt
|
|
8
7
|
import numpy as np
|
|
9
8
|
import rasterio
|
|
@@ -736,6 +735,7 @@ class ChangeDetection:
|
|
|
736
735
|
output_path="split_comparison.png",
|
|
737
736
|
):
|
|
738
737
|
"""Create a split comparison visualization showing before/after with change overlay."""
|
|
738
|
+
import cv2 # Lazy import to avoid QGIS opencv conflicts
|
|
739
739
|
|
|
740
740
|
# Load data
|
|
741
741
|
with rasterio.open(image1_path) as src:
|
geoai/detectron2.py
CHANGED
|
@@ -6,7 +6,6 @@ import os
|
|
|
6
6
|
import warnings
|
|
7
7
|
from typing import Dict, List, Optional, Tuple, Union
|
|
8
8
|
|
|
9
|
-
import cv2
|
|
10
9
|
import numpy as np
|
|
11
10
|
import rasterio
|
|
12
11
|
import torch
|
|
@@ -135,6 +134,8 @@ def detectron2_segment(
|
|
|
135
134
|
Returns:
|
|
136
135
|
Dict containing segmentation results and output file paths
|
|
137
136
|
"""
|
|
137
|
+
import cv2 # Lazy import to avoid QGIS opencv conflicts
|
|
138
|
+
|
|
138
139
|
check_detectron2()
|
|
139
140
|
|
|
140
141
|
# Load the model
|
|
@@ -315,6 +316,8 @@ def visualize_detectron2_results(
|
|
|
315
316
|
Returns:
|
|
316
317
|
Visualization image as numpy array
|
|
317
318
|
"""
|
|
319
|
+
import cv2 # Lazy import to avoid QGIS opencv conflicts
|
|
320
|
+
|
|
318
321
|
check_detectron2()
|
|
319
322
|
|
|
320
323
|
# Load the image
|
geoai/extract.py
CHANGED
|
@@ -6,7 +6,6 @@ import time
|
|
|
6
6
|
from typing import Any, Dict, Generator, List, Optional, Tuple, Union
|
|
7
7
|
|
|
8
8
|
# Third-Party Libraries
|
|
9
|
-
import cv2
|
|
10
9
|
import geopandas as gpd
|
|
11
10
|
import matplotlib.pyplot as plt
|
|
12
11
|
import numpy as np
|
|
@@ -440,6 +439,7 @@ class ObjectDetector:
|
|
|
440
439
|
Returns:
|
|
441
440
|
List of polygons as lists of (x, y) coordinates
|
|
442
441
|
"""
|
|
442
|
+
import cv2 # Lazy import to avoid QGIS opencv conflicts
|
|
443
443
|
|
|
444
444
|
# Get parameters from kwargs or use instance defaults
|
|
445
445
|
simplify_tolerance = kwargs.get("simplify_tolerance", self.simplify_tolerance)
|
|
@@ -637,6 +637,8 @@ class ObjectDetector:
|
|
|
637
637
|
Returns:
|
|
638
638
|
GeoDataFrame with objects
|
|
639
639
|
"""
|
|
640
|
+
import cv2 # Lazy import to avoid QGIS opencv conflicts
|
|
641
|
+
|
|
640
642
|
# Use class defaults if parameters not provided
|
|
641
643
|
simplify_tolerance = (
|
|
642
644
|
simplify_tolerance
|
|
@@ -1715,21 +1717,21 @@ class ObjectDetector:
|
|
|
1715
1717
|
confidence = None
|
|
1716
1718
|
try:
|
|
1717
1719
|
confidence = row.confidence
|
|
1718
|
-
except:
|
|
1720
|
+
except Exception:
|
|
1719
1721
|
pass
|
|
1720
1722
|
|
|
1721
1723
|
# Method 2: Try dictionary-style access
|
|
1722
1724
|
if confidence is None:
|
|
1723
1725
|
try:
|
|
1724
1726
|
confidence = row["confidence"]
|
|
1725
|
-
except:
|
|
1727
|
+
except Exception:
|
|
1726
1728
|
pass
|
|
1727
1729
|
|
|
1728
1730
|
# Method 3: Try accessing by index from the GeoDataFrame
|
|
1729
1731
|
if confidence is None:
|
|
1730
1732
|
try:
|
|
1731
1733
|
confidence = gdf.iloc[idx]["confidence"]
|
|
1732
|
-
except:
|
|
1734
|
+
except Exception:
|
|
1733
1735
|
pass
|
|
1734
1736
|
|
|
1735
1737
|
if confidence is not None:
|
|
@@ -1877,19 +1879,19 @@ class ObjectDetector:
|
|
|
1877
1879
|
confidence = None
|
|
1878
1880
|
try:
|
|
1879
1881
|
confidence = row.confidence
|
|
1880
|
-
except:
|
|
1882
|
+
except Exception:
|
|
1881
1883
|
pass
|
|
1882
1884
|
|
|
1883
1885
|
if confidence is None:
|
|
1884
1886
|
try:
|
|
1885
1887
|
confidence = row["confidence"]
|
|
1886
|
-
except:
|
|
1888
|
+
except Exception:
|
|
1887
1889
|
pass
|
|
1888
1890
|
|
|
1889
1891
|
if confidence is None:
|
|
1890
1892
|
try:
|
|
1891
1893
|
confidence = visible_gdf.iloc[idx]["confidence"]
|
|
1892
|
-
except:
|
|
1894
|
+
except Exception:
|
|
1893
1895
|
pass
|
|
1894
1896
|
|
|
1895
1897
|
if confidence is not None:
|
|
@@ -2165,6 +2167,7 @@ class ObjectDetector:
|
|
|
2165
2167
|
Returns:
|
|
2166
2168
|
GeoDataFrame with car detections and confidence values
|
|
2167
2169
|
"""
|
|
2170
|
+
import cv2 # Lazy import to avoid QGIS opencv conflicts
|
|
2168
2171
|
|
|
2169
2172
|
def _process_single_component(
|
|
2170
2173
|
component_mask: np.ndarray,
|
geoai/hf.py
CHANGED
|
@@ -343,7 +343,7 @@ def mask_generation(
|
|
|
343
343
|
# Try to convert from tensor or other format if needed
|
|
344
344
|
try:
|
|
345
345
|
mask_data = np.array(mask_data)
|
|
346
|
-
except:
|
|
346
|
+
except Exception:
|
|
347
347
|
print(f"Could not convert mask at index {i} to numpy array")
|
|
348
348
|
continue
|
|
349
349
|
|
|
@@ -395,7 +395,7 @@ def mask_generation(
|
|
|
395
395
|
try:
|
|
396
396
|
mask_data = np.array(mask_result)
|
|
397
397
|
score = 1.0 # Default score
|
|
398
|
-
except:
|
|
398
|
+
except Exception:
|
|
399
399
|
print(f"Could not process mask at index {i}")
|
|
400
400
|
continue
|
|
401
401
|
|
|
@@ -404,7 +404,7 @@ def mask_generation(
|
|
|
404
404
|
if not isinstance(mask_data, np.ndarray):
|
|
405
405
|
try:
|
|
406
406
|
mask_data = np.array(mask_data)
|
|
407
|
-
except:
|
|
407
|
+
except Exception:
|
|
408
408
|
print(f"Could not convert mask at index {i} to numpy array")
|
|
409
409
|
continue
|
|
410
410
|
|
geoai/moondream.py
CHANGED
|
@@ -1305,7 +1305,7 @@ class MoondreamGeo:
|
|
|
1305
1305
|
try:
|
|
1306
1306
|
summary_result = self.model.query(question=summary_prompt)
|
|
1307
1307
|
combined_answer = summary_result.get("answer", "")
|
|
1308
|
-
except:
|
|
1308
|
+
except Exception:
|
|
1309
1309
|
# Fall back to concatenation if summarization fails
|
|
1310
1310
|
combined_answer = " ".join([ta["answer"] for ta in tile_answers])
|
|
1311
1311
|
else:
|
|
@@ -1411,7 +1411,7 @@ class MoondreamGeo:
|
|
|
1411
1411
|
try:
|
|
1412
1412
|
summary_result = self.model.query(question=summary_prompt)
|
|
1413
1413
|
combined_caption = summary_result.get("answer", "")
|
|
1414
|
-
except:
|
|
1414
|
+
except Exception:
|
|
1415
1415
|
# Fall back to concatenation if summarization fails
|
|
1416
1416
|
combined_caption = " ".join([tc["caption"] for tc in tile_captions])
|
|
1417
1417
|
else:
|