A small test program for gauging the efficacy of Vertex AI for doing pool detection inference
- Go 98.5%
- Nix 1.3%
- Shell 0.2%
| doc | ||
| .gitignore | ||
| AGENTS.md | ||
| catalog.go | ||
| config.go | ||
| flake.lock | ||
| flake.nix | ||
| gcs.go | ||
| go.mod | ||
| go.sum | ||
| inference.go | ||
| main.go | ||
| manifest.go | ||
| README.md | ||
| scene.go | ||
| start-vertex-ai-test.sh | ||
| tile.go | ||
Vertex AI Test
Processes a Planet satellite imagery zip file: unzips, validates integrity, slices GeoTIFFs into PNG tiles, and uploads them to Google Cloud Storage. (Vertex AI batch inference coming soon.)
Build
go build ./...
Requires the tiff2rgba and tiffcrop CLI tools (from libtiff) at runtime. If
using Nix, nix develop provides them.
GCP prerequisites
The service account used for authentication needs the following IAM roles:
| Role | Purpose |
|---|---|
roles/storage.objectAdmin |
Read/write objects in the GCS bucket |
roles/aiplatform.user |
Create and manage Vertex AI batch prediction jobs |
Grant them via:
gcloud projects add-iam-policy-binding <PROJECT> \
--member="serviceAccount:<CLIENT_EMAIL>" \
--role="roles/storage.objectAdmin"
gcloud projects add-iam-policy-binding <PROJECT> \
--member="serviceAccount:<CLIENT_EMAIL>" \
--role="roles/aiplatform.user"
The <CLIENT_EMAIL> is the client_email field from your service account JSON key file.
Usage
vertex-ai-test [flags] <input.zip>
Required flags
| Flag | Env var | Description |
|---|---|---|
-bucket |
GCS_BUCKET |
GCS bucket name for tile uploads |
-project |
VERTEX_PROJECT or GOOGLE_CLOUD_PROJECT |
GCP project ID |
-model |
VERTEX_MODEL |
Vertex AI model ID (numeric ID from the console, not the display name) |
Authentication
Supply GCP credentials via one of:
-credsflag: path to a GCP service account JSON key fileGOOGLE_APPLICATION_CREDENTIALSenv var: path to the same JSON key file- ADC fallback: if neither is set, the GCE/GKE metadata server is tried
Example using a service account key file:
./vertex-ai-test \
-bucket my-bucket \
-project my-gcp-project \
-model 1234567890123456789 \
-creds /path/to/service-account.json \
scene.zip
Or equivalently with env vars:
export GCS_BUCKET=my-bucket
export VERTEX_PROJECT=my-gcp-project
export VERTEX_MODEL=1234567890123456789
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json
./vertex-ai-test scene.zip
Optional flags
| Flag | Default | Description |
|---|---|---|
-tilearea |
1000.0 |
Target tile area in square meters |
-gcs-prefix |
"" |
Optional prefix within the GCS bucket |
-location |
us-central1 |
GCP region for Vertex AI (or VERTEX_LOCATION env) |
-machine-type |
n1-standard-4 |
Batch prediction worker machine type |
-max-workers |
10 |
Max prediction worker count |
-batch-size |
64 |
Batch size per worker |
-debug |
false |
Enable debug-level logging |
-force |
false |
Re-upload tiles that already exist in GCS (by default they are skipped) |
-j |
8 |
Number of parallel GCS uploads |
Output
- Tiles are extracted to
./tmp/<scene-name>/tiles/<itemID>/<assetType>/<N>px/tile_X_Y.png - Uploaded to GCS at
gs://<bucket>/[<prefix>/]<catalogID>/<itemID>/<assetType>/<N>px/tile_X_Y.png