User Tools

Site Tools


samples:samples:aimodelrunner

Table of Contents

AIModelRunner sample

Documentation | Samples | AIModelRunner

Summary

Sample app for running Python-driven AI Models on TatukGIS Viewer/Layer.

Description

What the sample shows:

  • Loading image files (TIFF, etc.) into the GIS viewer
  • Executing AI/ML models on raster data via Python backend
  • RealEsrgan model for image upscaling (super-resolution)
  • MMRotate model for object detection and orientation
  • Selecting models from dropdown list
  • Background model execution with progress feedback
  • TGIS_AIPythonWorker for asynchronous model processing
  • TGIS_AIModelCustom for wrapping custom AI implementations
  • Dual-target .NET build (net6.0-windows + net4.8)
  • GisImageExporter for output raster generation
  • Handling long-running AI computations without UI blocking
  • Integration with Python environment and model libraries

What the sample shows:

  • Loading image files (TIFF, etc.) into the GIS viewer
  • Executing AI/ML models on raster data via Python backend
  • RealEsrgan model for image upscaling (super-resolution)
  • MMRotate model for object detection and orientation
  • Selecting models from dropdown list
  • Background model execution with progress feedback
  • TGIS_AIPythonWorker for asynchronous model processing
  • TGIS_AIModelCustom for wrapping custom AI implementations
  • Dual-target .NET build (net6.0-windows + net4.8)
  • GisImageExporter for output raster generation
  • Handling long-running AI computations without UI blocking
  • Integration with Python environment and model libraries

This sample demonstrates how to execute AI inference models (like Real-ESRGAN or custom ONNX/PyTorch models via Python wrappers) directly from TatukGIS. It exports the map state, executes a Python script, parses a JSON manifest, and maps the output (raster layers or vector detections) back onto the map.

Check following guide: Running AI Models in Developer Kernel to learn how to run custom AI models in TatukGIS DK environment.

This sample illustrates use of:

Name Description
PythonWorkerDefaultGet or create the default singleton worker and start it immediately.
TGIS_AIPythonWorker.EnqueueQueue a job for execution on the worker thread and return immediately.
TGIS_AIModelCustom.CreateInstantiates a custom AI model with a Python manager, model path, script template, required modules, and placeholder tokens.
TGIS_AIModel.InstallModulesInstalls the Python modules required by the model.
TGIS_AIModel.RunRuns the model for the specified input image.
TGIS_AIModelOutput.GetDetectionsReturns detections aggregated from all detection output items.
TGIS_AIModelOutput.GetDetectionLayersReturns detections converted into vector layers.
TGIS_AIModelOutput.GetLayersReturns file-backed layers produced by the AI output manifest.
TGIS_ImageExporter.ExportToImageExport viewer content to an image file using TGIS_PixelExportManager.
TGIS_ImageExporter.GetPixelSizeCalculate how a single pixel translates to geographic distance from a source viewer, based on its visible extent and viewer component size.

Code

This sample is available on the following platforms (click to view the source code on GitHub):

2026/07/05 05:38

Page Tools