$ cat node-template.py
O
Object Detection
// Detects objects in images and video. Returns bounding boxes, class labels, and confidence scores across 80 object categories.
Process
#yolo#object-detection#computer-vision#bounding-box#yolo26
template.py
1import os2import sys3import json4import traceback56from gais import Gais78INPUT_DIR = "/data/input"91011def main():12 try:13 input_json = sys.stdin.read()14 execution_input = json.loads(input_json)15 inputs = execution_input.get("inputs", {})1617 media = inputs.get("media", "")18 confidence = float(inputs.get("confidence", 0.25))19 iou_threshold = float(inputs.get("iou_threshold", 0.45))20 model_variant = inputs.get("model_variant", "yolo26n")21 classes_str = inputs.get("classes", "")2223 if not media:24 raise ValueError("Media input is required")2526 media_path = os.path.join(INPUT_DIR, media)27 if not os.path.exists(media_path):28 raise FileNotFoundError(f"Input file not found: {media_path}")2930 print(31 f"Detecting objects: confidence={confidence}, iou={iou_threshold}, "32 f"model={model_variant}, classes={classes_str or 'all'}",33 file=sys.stderr,34 )3536 result = Gais.detect.objects(37 media=media_path,38 confidence=confidence,39 iou_threshold=iou_threshold,40 model_variant=model_variant,41 classes=classes_str,42 )4344 result_data = json.loads(result.content)4546 frames = result_data.get("frames", [])47 total_detections = result_data.get("total_detections", 0)48 total_frames = result_data.get("total_frames", 1)49 model_used = result_data.get("model_used", model_variant)50 input_type = result_data.get("input_type", "image")51 processing_time = result_data.get("processing_time_ms", 0)5253 print(54 f"Detection complete: {total_detections} objects in {total_frames} frame(s), "55 f"model={model_used}, type={input_type}, "56 f"processing_time={processing_time}ms",57 file=sys.stderr,58 )5960 # Flat output — keys match OUTPUT_SCHEMA61 # frames is serialized as JSON Text for downstream Text consumers62 output = {63 "detections": json.dumps(frames),64 "total_detections": total_detections,65 "total_frames": total_frames,66 "model_used": model_used,67 "input_type": input_type,68 }69 print(json.dumps(output, indent=2))7071 except Exception as e:72 error_output = {73 "error": str(e),74 "errorType": type(e).__name__,75 "traceback": traceback.format_exc(),76 }77 print(json.dumps(error_output), file=sys.stderr)78 sys.exit(1)798081if __name__ == "__main__":82 main()$ git log --oneline
v1.5.0
HEAD
2026-05-07v1.2.02026-04-09