code: def view_warp(modelpath):
      pred = OfflinePredictor(
          PredictConfig(
              session_init=SmartInit(modelpath),
              model=Model(),
              input_names=["input"],
              output_names=[
                  "visualization/viz",
                  "STN1/affine",
                  "STN2/affine",
              ],
          )
      )
  
      xys = np.array(
          [
              [0, 0, 1],
              [WARP_TARGET_SIZE, 0, 1],
              [WARP_TARGET_SIZE, WARP_TARGET_SIZE, 1],
              [0, WARP_TARGET_SIZE, 1],
          ],
          dtype="float32",
      )
  
      def draw_rect(img, affine, c, offset=(0, 0)):
          a = np.transpose(affine)  # 3x2
          a = (np.matmul(xys, a) + list(offset)).astype("int32")
          cv2.line(img, tuple(a[0][::-1]), tuple(a[1][::-1]), c)
          cv2.line(img, tuple(a[1][::-1]), tuple(a[2][::-1]), c)
          cv2.line(img, tuple(a[2][::-1]), tuple(a[3][::-1]), c)
          cv2.line(img, tuple(a[3][::-1]), tuple(a[0][::-1]), c)
  
      ds = get_data(False)
      ds.reset_state()
      for k in ds:
          img, label = k
          outputs, affine1, affine2 = pred(img)
          for idx, viz in enumerate(outputs):
              viz = cv2.cvtColor(viz, cv2.COLOR_GRAY2BGR)
              # Here we assume the second branch focuses on the first digit
              draw_rect(viz, affine2[idx], (0, 0, 255))
              draw_rect(
                  viz, affine1[idx], (0, 0, 255), offset=[IMAGE_SIZE, 0]
              )
              cv2.imwrite("{:03d}.png".format(idx), (viz + 0.5) * 255)
          break
  
file_path: tensorpack/examples/SpatialTransformer/mnist-addition.py
imports: import argparse
  import numpy
  import os
  import cv2
  from tensorpack import tfv1
  from tensorpack import *
  from tensorpack.dataflow import dataset
  from tensorpack.tfutils import gradproc, optimizer, summary
label_desc: Use image node_id 4 for calling a global function with example usage: view_warp(modelpath) without return types