Supported TasksMask Generation

Mask Generation

Generate precise pixel-level masks for objects

Quick Start

import { geoai } from "@geobase-js/geoai";
 
// Initialize pipeline
const pipeline = await geoai.pipeline(
  [{ task: "mask-generation" }],
  providerParams
);
 
// Run with point input
const result = await pipeline.inference({
  inputs: {
    polygon: myPolygon,
    input: {
      type: "points",
      coordinates: [longitude, latitude],
    },
  },
  postProcessingParams: { maxMasks: 3 },
});
 
console.log(`Generated ${result.masks.features.length} masks`);
🎯

Generate precise object boundaries using point clicks, bounding boxes, or chained from object detection

Input Types

Point Input

input: {
  type: "points",
  coordinates: [longitude, latitude]  // Click on object center
}

Box Input

input: {
  type: "boxes",
  coordinates: [minLng, minLat, maxLng, maxLat]  // Bounding box around object
}

Post-Processing

postProcessingParams: {
  maxMasks: 1; // Maximum number of masks
}

Chained Pipeline

// Use with object detection pipeline
const pipeline = await geoai.pipeline(
  [
    { task: "object-detection" },
    {
      task: "mask-generation",
      modelId: "Xenova/slimsam-77-uniform",
      modelParams: { revision: "boxes" },
    },
  ],
  providerParams
);
💡

Point prompts work best when clicking object centers Box prompts need the “boxes” model revision for box inputs

Parameters

ParameterTypeDescription
polygonGeoJSON.Feature<Polygon>Area of interest
inputSegmentationInputPoint, box, or detection results
maxMasksnumberMaximum masks per prompt (default: 1)

Output

{
  detection: GeoJSON.FeatureCollection,  // Generated mask polygons
  geoRawImage: GeoRawImage           // Source imagery metadata
}