code: def test_net(
      net,
      image,
      text_threshold,
      link_threshold,
      low_text,
      cuda,
      poly,
      canvas_size=1280,
      mag_ratio=1.5,
  ):
      # resize
  
      (
          img_resized,
          target_ratio,
          size_heatmap,
      ) = imgproc.resize_aspect_ratio(
          image,
          canvas_size,
          interpolation=cv2.INTER_LINEAR,
          mag_ratio=mag_ratio,
      )
      ratio_h = ratio_w = 1 / target_ratio
  
      # preprocessing
      x = imgproc.normalizeMeanVariance(img_resized)
      x = torch.from_numpy(x).permute(2, 0, 1)  # [h, w, c] to [c, h, w]
      x = Variable(x.unsqueeze(0))  # [c, h, w] to [b, c, h, w]
      if cuda:
          x = x.cuda()
  
      # forward pass
      with torch.no_grad():
          y, feature = net(x)
  
      # make score and link map
      score_text = y[0, :, :, 0].cpu().data.numpy().astype(np.float32)
      score_link = y[0, :, :, 1].cpu().data.numpy().astype(np.float32)
  
      # NOTE
      score_text = score_text[: size_heatmap[0], : size_heatmap[1]]
      score_link = score_link[: size_heatmap[0], : size_heatmap[1]]
  
      # Post-processing
      boxes, polys = getDetBoxes(
          score_text,
          score_link,
          text_threshold,
          link_threshold,
          low_text,
          poly,
      )
  
      # coordinate adjustment
      boxes = adjustResultCoordinates(boxes, ratio_w, ratio_h)
      polys = adjustResultCoordinates(polys, ratio_w, ratio_h)
      for k in range(len(polys)):
          if polys[k] is None:
              polys[k] = boxes[k]
  
      # render results (optional)
      score_text = score_text.copy()
      render_score_text = imgproc.cvt2HeatmapImg(score_text)
      render_score_link = imgproc.cvt2HeatmapImg(score_link)
      render_img = [render_score_text, render_score_link]
      # ret_score_text = imgproc.cvt2HeatmapImg(render_img)
  
      return boxes, polys, render_img
  
imports: import os
  import re
  import itertools
  import cv2
  import time
  import numpy
  import torch
  from torch.autograd import Variable
  from utils.craft_utils import getDetBoxes, adjustResultCoordinates
  from data import imgproc
  from data.dataset import SynthTextDataSet
  import math
  import xml.etree.ElementTree
label_desc: Use image node_id 9 for calling a global function with example usage: test_net(net, image, text_threshold, link_threshold, low_text, cuda, poly, canvas_size, mag_ratio) and returns: boxes,  polys,  render_img