geoai 1.0.1 → 1.0.2
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.
- package/index.d.ts +546 -0
- package/package.json +1 -1
package/index.d.ts
ADDED
|
@@ -0,0 +1,546 @@
|
|
|
1
|
+
// Generated by dts-bundle-generator v9.5.1
|
|
2
|
+
|
|
3
|
+
import { ImageProcessor, PretrainedModelOptions, RawImage } from '@huggingface/transformers';
|
|
4
|
+
import * as ort from 'onnxruntime-web';
|
|
5
|
+
|
|
6
|
+
export interface Bounds {
|
|
7
|
+
north: number;
|
|
8
|
+
south: number;
|
|
9
|
+
east: number;
|
|
10
|
+
west: number;
|
|
11
|
+
}
|
|
12
|
+
declare class GeoRawImage extends RawImage {
|
|
13
|
+
private bounds;
|
|
14
|
+
private transform;
|
|
15
|
+
private crs;
|
|
16
|
+
constructor(data: Uint8ClampedArray | Uint8Array, width: number, height: number, channels: 1 | 2 | 3 | 4, bounds: Bounds, crs?: string);
|
|
17
|
+
/**
|
|
18
|
+
* Convert the image into patches.
|
|
19
|
+
*/
|
|
20
|
+
toPatches(patch_height: number, patch_width: number, { padding }?: {
|
|
21
|
+
padding?: boolean | undefined;
|
|
22
|
+
}): Promise<GeoRawImage[][]>;
|
|
23
|
+
/**
|
|
24
|
+
* Static function to join a 2D array of RawImage patches into a single GeoRawImage.
|
|
25
|
+
* This function assumes the patches are contiguous and form a complete grid.
|
|
26
|
+
* @param patches A 2D array of RawImage objects to be joined.
|
|
27
|
+
* @param bounds The bounds of the final, merged image.
|
|
28
|
+
* @param crs The Coordinate Reference System of the final, merged image.
|
|
29
|
+
* @returns A promise that resolves to a single GeoRawImage containing the joined data.
|
|
30
|
+
*/
|
|
31
|
+
static fromPatches(patches: RawImage[][], bounds: Bounds, crs: string): GeoRawImage;
|
|
32
|
+
/**
|
|
33
|
+
* Convert pixel coordinates to world coordinates
|
|
34
|
+
*/
|
|
35
|
+
pixelToWorld(x: number, y: number): [
|
|
36
|
+
number,
|
|
37
|
+
number
|
|
38
|
+
];
|
|
39
|
+
/**
|
|
40
|
+
* Convert world coordinates to pixel coordinates
|
|
41
|
+
*/
|
|
42
|
+
worldToPixel(lon: number, lat: number): [
|
|
43
|
+
number,
|
|
44
|
+
number
|
|
45
|
+
];
|
|
46
|
+
/**
|
|
47
|
+
* Get the bounds of the image
|
|
48
|
+
*/
|
|
49
|
+
getBounds(): Bounds;
|
|
50
|
+
/**
|
|
51
|
+
* Get the CRS of the image
|
|
52
|
+
*/
|
|
53
|
+
getCRS(): string;
|
|
54
|
+
/**
|
|
55
|
+
* Create a new GeoRawImage from a RawImage and georeferencing information
|
|
56
|
+
*/
|
|
57
|
+
static fromRawImage(rawImage: RawImage, bounds: Bounds, crs?: string): GeoRawImage;
|
|
58
|
+
/**
|
|
59
|
+
* Override the clone method to include georeferencing information
|
|
60
|
+
*/
|
|
61
|
+
clone(): GeoRawImage;
|
|
62
|
+
}
|
|
63
|
+
export type ObjectDectection = {
|
|
64
|
+
label: string;
|
|
65
|
+
score: number;
|
|
66
|
+
box: [
|
|
67
|
+
number,
|
|
68
|
+
number,
|
|
69
|
+
number,
|
|
70
|
+
number
|
|
71
|
+
];
|
|
72
|
+
};
|
|
73
|
+
declare const postProcessYoloOutput: (model_outputs: any, pixel_values: {
|
|
74
|
+
dims: number[];
|
|
75
|
+
}, rawImage: RawImage, id2label: {
|
|
76
|
+
[key: number]: string;
|
|
77
|
+
}) => ObjectDectection[];
|
|
78
|
+
declare const parametersChanged: (instance: any, model_id: string, providerParams: any, modelParams?: PretrainedModelOptions) => boolean;
|
|
79
|
+
declare const detectionsToGeoJSON: (detections: ObjectDectection[], geoRawImage: GeoRawImage) => GeoJSON.FeatureCollection;
|
|
80
|
+
declare const maskToGeoJSON: (masks: any, geoRawImage: GeoRawImage, thresholds?: number[]) => GeoJSON.FeatureCollection[];
|
|
81
|
+
declare const polygonsEqual: (polygon1: GeoJSON.Feature | null, polygon2: GeoJSON.Feature | null) => boolean;
|
|
82
|
+
declare abstract class MapSource {
|
|
83
|
+
protected abstract getTileUrlFromTileCoords(tileCoords: [
|
|
84
|
+
number,
|
|
85
|
+
number,
|
|
86
|
+
number
|
|
87
|
+
], instance: any, bands?: number[], expression?: string): string;
|
|
88
|
+
getImage(polygon: any, bands?: number[], expression?: string, zoomLevel?: number, requiresSquare?: boolean, // default is false,
|
|
89
|
+
stitch?: boolean): Promise<GeoRawImage | GeoRawImage[][]>;
|
|
90
|
+
}
|
|
91
|
+
declare class Mapbox extends MapSource {
|
|
92
|
+
apiKey: string;
|
|
93
|
+
style: string;
|
|
94
|
+
constructor(apiKey: string, style: string);
|
|
95
|
+
protected getTileUrlFromTileCoords(tileCoords: [
|
|
96
|
+
number,
|
|
97
|
+
number,
|
|
98
|
+
number
|
|
99
|
+
], instance: Mapbox): string;
|
|
100
|
+
}
|
|
101
|
+
export interface GeobaseConfig {
|
|
102
|
+
projectRef: string;
|
|
103
|
+
cogImagery: string;
|
|
104
|
+
apikey: string;
|
|
105
|
+
}
|
|
106
|
+
declare class Geobase extends MapSource {
|
|
107
|
+
projectRef: string;
|
|
108
|
+
cogImagery: string;
|
|
109
|
+
apikey: string;
|
|
110
|
+
constructor(config: GeobaseConfig);
|
|
111
|
+
protected getTileUrlFromTileCoords(tileCoords: [
|
|
112
|
+
number,
|
|
113
|
+
number,
|
|
114
|
+
number
|
|
115
|
+
], instance: Geobase, bands?: number[], expression?: string): string;
|
|
116
|
+
}
|
|
117
|
+
export interface EsriConfig {
|
|
118
|
+
serviceUrl?: string;
|
|
119
|
+
serviceName?: string;
|
|
120
|
+
tileSize?: number;
|
|
121
|
+
attribution?: string;
|
|
122
|
+
}
|
|
123
|
+
declare class Esri extends MapSource {
|
|
124
|
+
serviceUrl: string;
|
|
125
|
+
serviceName: string;
|
|
126
|
+
tileSize: number;
|
|
127
|
+
attribution: string;
|
|
128
|
+
constructor(config: EsriConfig);
|
|
129
|
+
protected getTileUrlFromTileCoords(tileCoords: [
|
|
130
|
+
number,
|
|
131
|
+
number,
|
|
132
|
+
number
|
|
133
|
+
], instance: Esri): string;
|
|
134
|
+
}
|
|
135
|
+
declare abstract class BaseModel {
|
|
136
|
+
protected static instance: BaseModel | null;
|
|
137
|
+
protected providerParams: ProviderParams;
|
|
138
|
+
protected dataProvider: Mapbox | Geobase | Esri | undefined;
|
|
139
|
+
protected model_id: string;
|
|
140
|
+
protected initialized: boolean;
|
|
141
|
+
protected modelParams?: PretrainedModelOptions;
|
|
142
|
+
protected constructor(model_id: string, providerParams: ProviderParams, modelParams?: PretrainedModelOptions);
|
|
143
|
+
protected initialize(): Promise<void>;
|
|
144
|
+
protected initializeDataProvider(): void;
|
|
145
|
+
/**
|
|
146
|
+
* Converts a GeoJSON polygon feature into a GeoRawImage using the configured data provider.
|
|
147
|
+
*
|
|
148
|
+
* @param polygon - The GeoJSON Feature representing the area of interest.
|
|
149
|
+
* @param zoomLevel - (Optional) The zoom level to use when retrieving the image.
|
|
150
|
+
* @param bands - (Optional) An array of band indices to select specific bands from the imagery.
|
|
151
|
+
* @param expression - (Optional) A string expression to apply to the image bands (e.g., for band math).
|
|
152
|
+
* @param requiresSquare - (default false) Whether to return a square image.
|
|
153
|
+
* @returns A Promise that resolves to a GeoRawImage corresponding to the input polygon.
|
|
154
|
+
* @throws {Error} If the data provider is not initialized.
|
|
155
|
+
*/
|
|
156
|
+
protected polygonToImage(polygon: GeoJSON.Feature, zoomLevel?: number, bands?: number[], expression?: string, requiresSquare?: boolean, stitch?: boolean): Promise<GeoRawImage | GeoRawImage[][]>;
|
|
157
|
+
protected abstract initializeModel(): Promise<void>;
|
|
158
|
+
abstract inference(params: InferenceParams): Promise<unknown>;
|
|
159
|
+
}
|
|
160
|
+
export interface SegmentationResult {
|
|
161
|
+
masks: GeoJSON.FeatureCollection;
|
|
162
|
+
geoRawImage: GeoRawImage;
|
|
163
|
+
}
|
|
164
|
+
declare class MaskGeneration extends BaseModel {
|
|
165
|
+
protected static instance: MaskGeneration | null;
|
|
166
|
+
private model;
|
|
167
|
+
private processor;
|
|
168
|
+
private cachedPolygon;
|
|
169
|
+
private cachedEmbeddings;
|
|
170
|
+
private cachedGeoRawImage;
|
|
171
|
+
private constructor();
|
|
172
|
+
static getInstance(model_id: string, providerParams: ProviderParams, modelParams?: PretrainedModelOptions): Promise<{
|
|
173
|
+
instance: MaskGeneration;
|
|
174
|
+
}>;
|
|
175
|
+
protected initializeModel(): Promise<void>;
|
|
176
|
+
/**
|
|
177
|
+
* Gets or computes image embeddings for the given polygon
|
|
178
|
+
* Uses cached embeddings if polygon hasn't changed
|
|
179
|
+
*/
|
|
180
|
+
private getOrComputeEmbeddings;
|
|
181
|
+
/**
|
|
182
|
+
* Performs segmentation on a geographic area based on the provided input parameters.
|
|
183
|
+
*
|
|
184
|
+
* @param params - Inference parameters containing:
|
|
185
|
+
* - inputs: Object containing polygon and segmentation input
|
|
186
|
+
* - postProcessingParams: Optional parameters for post-processing
|
|
187
|
+
* - mapSourceParams: Optional parameters for map source configuration
|
|
188
|
+
*
|
|
189
|
+
* @returns Promise<SegmentationResult> containing:
|
|
190
|
+
* - masks: GeoJSON representation of the segmentation masks
|
|
191
|
+
* - geoRawImage: Raw image data with geographic reference
|
|
192
|
+
*
|
|
193
|
+
* @throws {Error} If data provider is not initialized
|
|
194
|
+
* @throws {Error} If model or processor is not initialized
|
|
195
|
+
* @throws {Error} If segmentation process fails
|
|
196
|
+
* @throws {Error} If input type is not supported
|
|
197
|
+
*/
|
|
198
|
+
inference(params: InferenceParams): Promise<SegmentationResult>;
|
|
199
|
+
getImageEmbeddings(params: InferenceParams): Promise<{
|
|
200
|
+
image_embeddings: any;
|
|
201
|
+
geoRawImage: GeoRawImage;
|
|
202
|
+
}>;
|
|
203
|
+
}
|
|
204
|
+
declare abstract class BaseDetectionModel extends BaseModel {
|
|
205
|
+
protected model: ort.InferenceSession | undefined;
|
|
206
|
+
protected zoom?: number;
|
|
207
|
+
protected processor: ImageProcessor | undefined;
|
|
208
|
+
protected constructor(model_id: string, providerParams: ProviderParams, modelParams?: PretrainedModelOptions);
|
|
209
|
+
protected initializeModel(): Promise<void>;
|
|
210
|
+
protected postProcessor(outputs: any, geoRawImage: GeoRawImage): Promise<GeoJSON.FeatureCollection>;
|
|
211
|
+
inference(params: InferenceParams): Promise<ObjectDetectionResults>;
|
|
212
|
+
}
|
|
213
|
+
declare class SolarPanelDetection extends BaseDetectionModel {
|
|
214
|
+
private static instanceRef;
|
|
215
|
+
private constructor();
|
|
216
|
+
static getInstance(model_id: string, providerParams: ProviderParams, modelParams?: PretrainedModelOptions): Promise<{
|
|
217
|
+
instance: SolarPanelDetection;
|
|
218
|
+
}>;
|
|
219
|
+
}
|
|
220
|
+
declare class ShipDetection extends BaseDetectionModel {
|
|
221
|
+
private static instanceRef;
|
|
222
|
+
private constructor();
|
|
223
|
+
static getInstance(model_id: string, providerParams: ProviderParams, modelParams?: PretrainedModelOptions): Promise<{
|
|
224
|
+
instance: ShipDetection;
|
|
225
|
+
}>;
|
|
226
|
+
}
|
|
227
|
+
declare class CarDetection extends BaseDetectionModel {
|
|
228
|
+
private static instanceRef;
|
|
229
|
+
private constructor();
|
|
230
|
+
static getInstance(model_id: string, providerParams: ProviderParams, modelParams?: PretrainedModelOptions): Promise<{
|
|
231
|
+
instance: CarDetection;
|
|
232
|
+
}>;
|
|
233
|
+
}
|
|
234
|
+
declare class BuildingDetection extends BaseDetectionModel {
|
|
235
|
+
private static instanceRef;
|
|
236
|
+
private constructor();
|
|
237
|
+
static getInstance(model_id: string, providerParams: ProviderParams, modelParams?: PretrainedModelOptions): Promise<{
|
|
238
|
+
instance: BuildingDetection;
|
|
239
|
+
}>;
|
|
240
|
+
}
|
|
241
|
+
declare class WetLandSegmentation extends BaseModel {
|
|
242
|
+
protected static instance: WetLandSegmentation | null;
|
|
243
|
+
protected model: ort.InferenceSession | undefined;
|
|
244
|
+
protected processor: ImageProcessor | undefined;
|
|
245
|
+
private constructor();
|
|
246
|
+
static getInstance(model_id: string, providerParams: ProviderParams, modelParams?: PretrainedModelOptions): Promise<{
|
|
247
|
+
instance: WetLandSegmentation;
|
|
248
|
+
}>;
|
|
249
|
+
protected initializeModel(): Promise<void>;
|
|
250
|
+
inference(params: InferenceParams): Promise<ObjectDetectionResults>;
|
|
251
|
+
protected postProcessor(outputs: any, geoRawImage: GeoRawImage): Promise<GeoJSON.FeatureCollection>;
|
|
252
|
+
}
|
|
253
|
+
declare class LandCoverClassification extends BaseModel {
|
|
254
|
+
protected static instance: LandCoverClassification | null;
|
|
255
|
+
private model;
|
|
256
|
+
private classes;
|
|
257
|
+
private colors;
|
|
258
|
+
private processor;
|
|
259
|
+
private constructor();
|
|
260
|
+
static getInstance(model_id: string, providerParams: ProviderParams, modelParams?: PretrainedModelOptions): Promise<{
|
|
261
|
+
instance: LandCoverClassification;
|
|
262
|
+
}>;
|
|
263
|
+
protected initializeModel(): Promise<void>;
|
|
264
|
+
inference(params: InferenceParams): Promise<any>;
|
|
265
|
+
}
|
|
266
|
+
declare class ObjectDetection extends BaseModel {
|
|
267
|
+
protected static instance: ObjectDetection | null;
|
|
268
|
+
private model;
|
|
269
|
+
private processor;
|
|
270
|
+
private constructor();
|
|
271
|
+
static getInstance(model_id: string, providerParams: ProviderParams, modelParams?: PretrainedModelOptions): Promise<{
|
|
272
|
+
instance: ObjectDetection;
|
|
273
|
+
}>;
|
|
274
|
+
protected initializeModel(): Promise<void>;
|
|
275
|
+
/**
|
|
276
|
+
* Performs object detection on a geographic area specified by a GeoJSON polygon.
|
|
277
|
+
*
|
|
278
|
+
* @param polygon - A GeoJSON Feature representing the geographic area to analyze
|
|
279
|
+
* @param confidence - Detection confidence threshold between 0 and 1. Detections below this threshold will be filtered out. Defaults to 0.9
|
|
280
|
+
* @returns Promise<ObjectDetectionResults> containing detected objects as GeoJSON features and the raw image used for detection
|
|
281
|
+
* @throws {Error} If data provider, model or processor are not properly initialized
|
|
282
|
+
*/
|
|
283
|
+
inference(params: InferenceParams): Promise<ObjectDetectionResults>;
|
|
284
|
+
}
|
|
285
|
+
declare class OilStorageTankDetection extends BaseModel {
|
|
286
|
+
protected static instance: OilStorageTankDetection | null;
|
|
287
|
+
protected model: ort.InferenceSession | undefined;
|
|
288
|
+
protected processor: ImageProcessor | undefined;
|
|
289
|
+
private constructor();
|
|
290
|
+
static getInstance(model_id: string, providerParams: ProviderParams, modelParams?: PretrainedModelOptions): Promise<{
|
|
291
|
+
instance: OilStorageTankDetection;
|
|
292
|
+
}>;
|
|
293
|
+
protected initializeModel(): Promise<void>;
|
|
294
|
+
inference(params: InferenceParams): Promise<ObjectDetectionResults>;
|
|
295
|
+
protected postProcessor(outputs: any, geoRawImage: GeoRawImage, CONFIDENCE_THRESHOLD?: number, NMS_THRESHOLD?: number): Promise<GeoJSON.FeatureCollection>;
|
|
296
|
+
}
|
|
297
|
+
export interface ConvertPredParams {
|
|
298
|
+
pred_bbox: number[][];
|
|
299
|
+
org_img_shape: [
|
|
300
|
+
number,
|
|
301
|
+
number
|
|
302
|
+
];
|
|
303
|
+
valid_scale: [
|
|
304
|
+
number,
|
|
305
|
+
number
|
|
306
|
+
];
|
|
307
|
+
conf_thresh: number;
|
|
308
|
+
}
|
|
309
|
+
export interface NMSOptions {
|
|
310
|
+
conf_thres?: number;
|
|
311
|
+
iou_thres?: number;
|
|
312
|
+
merge?: boolean;
|
|
313
|
+
classes?: number[];
|
|
314
|
+
multi_label?: boolean;
|
|
315
|
+
agnostic?: boolean;
|
|
316
|
+
without_iouthres?: boolean;
|
|
317
|
+
}
|
|
318
|
+
declare class OrientedObjectDetection extends BaseModel {
|
|
319
|
+
protected static instance: OrientedObjectDetection | null;
|
|
320
|
+
protected model: ort.InferenceSession | undefined;
|
|
321
|
+
protected initialized: boolean;
|
|
322
|
+
protected processor: ImageProcessor | undefined;
|
|
323
|
+
protected classes: string[] | undefined;
|
|
324
|
+
protected constructor(model_id: string, providerParams: ProviderParams, modelParams?: PretrainedModelOptions);
|
|
325
|
+
static getInstance(model_id: string, providerParams: ProviderParams, modelParams?: PretrainedModelOptions): Promise<{
|
|
326
|
+
instance: OrientedObjectDetection;
|
|
327
|
+
}>;
|
|
328
|
+
protected initializeModel(): Promise<void>;
|
|
329
|
+
/**
|
|
330
|
+
* Performs object detection on a given geographic polygon.
|
|
331
|
+
* @param polygon - A GeoJSON Feature representing the area for detection
|
|
332
|
+
* @param options - Optional NMS (Non-Maximum Suppression) configuration options
|
|
333
|
+
* @param {NMSOptions} [options={}] - Configuration options for NMS post-processing
|
|
334
|
+
* @returns {Promise<ObjectDetectionResults>} A promise that resolves to the detection results, including the detections array and raw image
|
|
335
|
+
* @throws {Error} If the data provider or model is not properly initialized
|
|
336
|
+
*/
|
|
337
|
+
inference(params: InferenceParams): Promise<ObjectDetectionResults>;
|
|
338
|
+
protected convertPred({ pred_bbox, org_img_shape, valid_scale, conf_thresh, }: ConvertPredParams): number[][];
|
|
339
|
+
/**
|
|
340
|
+
* Performs Rotate-Non-Maximum Suppression (RNMS) on inference results.
|
|
341
|
+
* @param prediction Array of predictions with shape (batch_size, num_boxes, [xywh, score, num_classes, num_angles]).
|
|
342
|
+
* @param conf_thres Confidence threshold.
|
|
343
|
+
* @param iou_thres IoU threshold.
|
|
344
|
+
* @param classes Array of class indices to filter by.
|
|
345
|
+
* @param without_iouthres Whether to skip IoU thresholding.
|
|
346
|
+
* @returns Array of filtered boxes after NMS.
|
|
347
|
+
*/
|
|
348
|
+
protected nonMaxSuppression4Points(prediction: number[][][], { conf_thres, iou_thres, classes, multi_label, without_iouthres, }?: NMSOptions): number[][][];
|
|
349
|
+
/**
|
|
350
|
+
* Polygonal NMS implementation.
|
|
351
|
+
* @param dets Array of polygons with shape (num_detections, [poly]).
|
|
352
|
+
* @param scores Array of confidence scores with shape (num_detections, 1).
|
|
353
|
+
* @param thresh IoU threshold.
|
|
354
|
+
* @returns Array of indices to keep after NMS.
|
|
355
|
+
*/
|
|
356
|
+
protected pyCpuNmsPolyFast(dets: number[][], scores: number[], thresh: number): number[];
|
|
357
|
+
protected postProcessor(outputs: any, geoRawImage: GeoRawImage, options?: NMSOptions): Promise<any>;
|
|
358
|
+
}
|
|
359
|
+
declare class ZeroShotObjectDetection extends BaseModel {
|
|
360
|
+
protected static instance: ZeroShotObjectDetection | null;
|
|
361
|
+
private detector;
|
|
362
|
+
rawDetections: any[];
|
|
363
|
+
protected constructor(model_id: string, providerParams: ProviderParams, modelParams?: PretrainedModelOptions);
|
|
364
|
+
static getInstance(model_id: string, providerParams: ProviderParams, modelParams?: PretrainedModelOptions): Promise<{
|
|
365
|
+
instance: ZeroShotObjectDetection;
|
|
366
|
+
}>;
|
|
367
|
+
protected initializeModel(): Promise<void>;
|
|
368
|
+
/**
|
|
369
|
+
* Performs object detection on a geographic area using a zero-shot learning model
|
|
370
|
+
* @param polygon - A GeoJSON Feature representing the geographic area to analyze
|
|
371
|
+
* @param text - Label or array of labels to detect in the image
|
|
372
|
+
* @param options - Detection configuration options
|
|
373
|
+
* @param options.topk - Maximum number of detections to return (default: 4)
|
|
374
|
+
* @param options.threshold - Confidence threshold for detections (default: 0.2)
|
|
375
|
+
* @returns Promise resolving to object detection results containing GeoJSON features and raw image data
|
|
376
|
+
* @throws Error if data provider is not initialized
|
|
377
|
+
*/
|
|
378
|
+
inference(params: InferenceParams): Promise<ObjectDetectionResults>;
|
|
379
|
+
}
|
|
380
|
+
declare class BuildingFootPrintSegmentation extends BaseModel {
|
|
381
|
+
protected static instance: BuildingFootPrintSegmentation | null;
|
|
382
|
+
protected model: ort.InferenceSession | undefined;
|
|
383
|
+
protected processor: ImageProcessor | undefined;
|
|
384
|
+
private constructor();
|
|
385
|
+
static getInstance(model_id: string, providerParams: ProviderParams, modelParams?: PretrainedModelOptions): Promise<{
|
|
386
|
+
instance: BuildingFootPrintSegmentation;
|
|
387
|
+
}>;
|
|
388
|
+
protected initializeModel(): Promise<void>;
|
|
389
|
+
inference(params: InferenceParams): Promise<ObjectDetectionResults>;
|
|
390
|
+
protected postProcessor(output: GeoRawImage, CONFIDENCE_THRESHOLD?: number, minArea?: number): Promise<GeoJSON.FeatureCollection>;
|
|
391
|
+
}
|
|
392
|
+
declare class ImageFeatureExtraction extends BaseModel {
|
|
393
|
+
protected static instance: ImageFeatureExtraction | null;
|
|
394
|
+
private extractor;
|
|
395
|
+
private patchSize;
|
|
396
|
+
private constructor();
|
|
397
|
+
static getInstance(model_id: string, providerParams: ProviderParams, modelParams?: PretrainedModelOptions): Promise<{
|
|
398
|
+
instance: ImageFeatureExtraction;
|
|
399
|
+
}>;
|
|
400
|
+
protected initializeModel(): Promise<void>;
|
|
401
|
+
/**
|
|
402
|
+
* Performs image feature extraction on a geographic area specified by a GeoJSON polygon.
|
|
403
|
+
* Extracts dense feature representations using DINOv3 and computes patch-to-patch similarities.
|
|
404
|
+
*
|
|
405
|
+
* @param params - Inference parameters containing polygon and processing options
|
|
406
|
+
* @returns Promise<ImageFeatureExtractionResults> containing feature vectors, similarity matrix, and metadata
|
|
407
|
+
* @throws {Error} If data provider, model or processor are not properly initialized
|
|
408
|
+
*/
|
|
409
|
+
inference(params: InferenceParams): Promise<ImageFeatureExtractionResults>;
|
|
410
|
+
}
|
|
411
|
+
export type MapboxParams = {
|
|
412
|
+
provider: "mapbox";
|
|
413
|
+
apiKey: string;
|
|
414
|
+
style: string;
|
|
415
|
+
};
|
|
416
|
+
export type SentinelParams = {
|
|
417
|
+
provider: "sentinel";
|
|
418
|
+
apiKey: string;
|
|
419
|
+
};
|
|
420
|
+
export type GeobaseParams = {
|
|
421
|
+
provider: "geobase";
|
|
422
|
+
apikey: string;
|
|
423
|
+
cogImagery: string;
|
|
424
|
+
projectRef: string;
|
|
425
|
+
};
|
|
426
|
+
export type EsriParams = {
|
|
427
|
+
provider: "esri";
|
|
428
|
+
serviceUrl?: string;
|
|
429
|
+
serviceName?: string;
|
|
430
|
+
tileSize?: number;
|
|
431
|
+
attribution?: string;
|
|
432
|
+
};
|
|
433
|
+
export interface InferenceInputs {
|
|
434
|
+
polygon: GeoJSON.Feature;
|
|
435
|
+
classLabel?: string;
|
|
436
|
+
[key: string]: unknown;
|
|
437
|
+
}
|
|
438
|
+
export type PostProcessingParams = {
|
|
439
|
+
[key: string]: unknown;
|
|
440
|
+
};
|
|
441
|
+
export interface MapSourceParams {
|
|
442
|
+
zoomLevel?: number;
|
|
443
|
+
bands?: number[];
|
|
444
|
+
expression?: string;
|
|
445
|
+
}
|
|
446
|
+
export interface InferenceParams {
|
|
447
|
+
inputs: InferenceInputs;
|
|
448
|
+
postProcessingParams?: PostProcessingParams;
|
|
449
|
+
mapSourceParams?: MapSourceParams;
|
|
450
|
+
}
|
|
451
|
+
export type ProviderParams = MapboxParams | SentinelParams | GeobaseParams | EsriParams;
|
|
452
|
+
export type HuggingFaceModelTask = "mask-generation" | "zero-shot-object-detection" | "zero-shot-image-classification" | "object-detection" | "oriented-object-detection" | "image-feature-extraction";
|
|
453
|
+
export type GeobaseAiModelTask = "damage-assessment" | "vegetation-classification" | "land-cover-classification" | "land-use-classification" | "land-cover-change-detection" | "land-use-change-detection" | "solar-panel-detection" | "ship-detection" | "car-detection" | "wetland-segmentation" | "building-detection" | "oil-storage-tank-detection" | "building-footprint-segmentation";
|
|
454
|
+
export type ModelInstance = MaskGeneration | ZeroShotObjectDetection | ObjectDetection | OrientedObjectDetection | LandCoverClassification | SolarPanelDetection | ShipDetection | CarDetection | WetLandSegmentation | BuildingDetection | OilStorageTankDetection | BuildingFootPrintSegmentation | ImageFeatureExtraction;
|
|
455
|
+
export type ModelConfig = {
|
|
456
|
+
task: HuggingFaceModelTask | GeobaseAiModelTask;
|
|
457
|
+
library: string;
|
|
458
|
+
description: string;
|
|
459
|
+
examples?: string[];
|
|
460
|
+
geobase_ai_pipeline: (params: ProviderParams, modelId?: string, modelParams?: PretrainedModelOptions) => Promise<{
|
|
461
|
+
instance: ModelInstance;
|
|
462
|
+
}>;
|
|
463
|
+
chainableTasks?: string[];
|
|
464
|
+
ioConfig?: {
|
|
465
|
+
inputs: any;
|
|
466
|
+
outputs: any;
|
|
467
|
+
};
|
|
468
|
+
defaultModelId?: string;
|
|
469
|
+
modelParams?: PretrainedModelOptions;
|
|
470
|
+
};
|
|
471
|
+
export interface SegmentationResults {
|
|
472
|
+
detections: GeoJSON.FeatureCollection;
|
|
473
|
+
masks: GeoJSON.FeatureCollection;
|
|
474
|
+
geoRawImage: GeoRawImage;
|
|
475
|
+
rawDetections: any[];
|
|
476
|
+
}
|
|
477
|
+
export interface ObjectDetectionResults {
|
|
478
|
+
detections: GeoJSON.FeatureCollection;
|
|
479
|
+
geoRawImage: GeoRawImage;
|
|
480
|
+
}
|
|
481
|
+
export interface ImageFeatureExtractionResults {
|
|
482
|
+
features: number[][];
|
|
483
|
+
similarityMatrix: number[][];
|
|
484
|
+
patchSize: number;
|
|
485
|
+
geoRawImage: GeoRawImage;
|
|
486
|
+
metadata: {
|
|
487
|
+
numPatches: number;
|
|
488
|
+
featureDimensions: number;
|
|
489
|
+
modelId: string;
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
export interface ChainInstance {
|
|
493
|
+
inference: (inputs: InferenceParams) => Promise<ObjectDetectionResults | SegmentationResults>;
|
|
494
|
+
}
|
|
495
|
+
export interface TaskConfig {
|
|
496
|
+
task: string;
|
|
497
|
+
modelId?: string;
|
|
498
|
+
modelParams?: PretrainedModelOptions;
|
|
499
|
+
}
|
|
500
|
+
declare class Pipeline {
|
|
501
|
+
/**
|
|
502
|
+
* Builds a dependency graph from modelRegistry chainableTasks
|
|
503
|
+
*/
|
|
504
|
+
private static buildTaskGraph;
|
|
505
|
+
/**
|
|
506
|
+
* Finds all valid task chains using BFS
|
|
507
|
+
*/
|
|
508
|
+
static findValidChains(tasks: string[]): string[][];
|
|
509
|
+
/**
|
|
510
|
+
* Orders tasks in a valid chainable sequence
|
|
511
|
+
*/
|
|
512
|
+
private static orderChainTasks;
|
|
513
|
+
/**
|
|
514
|
+
* Validates and reorders tasks array in-place
|
|
515
|
+
*/
|
|
516
|
+
private static validateChainCompatibility;
|
|
517
|
+
/**
|
|
518
|
+
* Validates input for a specific task
|
|
519
|
+
*/
|
|
520
|
+
private static validateTaskInput;
|
|
521
|
+
/**
|
|
522
|
+
* Creates a pipeline for a single task or a chain of tasks
|
|
523
|
+
* @param taskOrTasks Single task or list of tasks to chain
|
|
524
|
+
* @param providerParams Provider parameters
|
|
525
|
+
* @returns A function that takes inputs and returns the output of the last task in the chain
|
|
526
|
+
*/
|
|
527
|
+
static pipeline(taskOrTasks: TaskConfig[], providerParams: ProviderParams): Promise<ModelInstance | ChainInstance>;
|
|
528
|
+
static listTasks(): string[];
|
|
529
|
+
static listModels(): ModelConfig[];
|
|
530
|
+
}
|
|
531
|
+
export declare const geoai: {
|
|
532
|
+
pipeline: typeof Pipeline.pipeline;
|
|
533
|
+
tasks: typeof Pipeline.listTasks;
|
|
534
|
+
models: typeof Pipeline.listModels;
|
|
535
|
+
validateChain: typeof Pipeline.findValidChains;
|
|
536
|
+
};
|
|
537
|
+
|
|
538
|
+
declare namespace utils {
|
|
539
|
+
export { detectionsToGeoJSON, maskToGeoJSON, parametersChanged, polygonsEqual, postProcessYoloOutput };
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
export {
|
|
543
|
+
utils,
|
|
544
|
+
};
|
|
545
|
+
|
|
546
|
+
export {};
|