code: def extract_features(
      detection_model, image_path, input_boxes=None, feat_name="fc6"
  ):
      im, im_scale = _image_transform(image_path)
      if input_boxes is not None:
          if isinstance(input_boxes, np.ndarray):
              input_boxes = torch.from_numpy(input_boxes.copy())
          input_boxes *= im_scale
      img_tensor, im_scales = [im], [im_scale]
      current_img_list = to_image_list(img_tensor, size_divisible=32)
      current_img_list = current_img_list.to("cuda")
      with torch.no_grad():
          output = detection_model(
              current_img_list, input_boxes=input_boxes
          )
  
      if input_boxes is None:
          feat_list, bbox_list = _process_feature_extraction(
              output, im_scales, feat_name
          )
          feat = feat_list[0].cpu().numpy()
          bbox = bbox_list[0].cpu().numpy() / im_scale
      else:
          feat = output[0][feat_name].cpu().numpy()
          bbox = output[0]["proposals"][0].bbox.cpu().numpy() / im_scale
  
      return feat, bbox
  
file_path: mmf/mmf/projects/m4c/scripts/extract_ocr_frcn_feature.py
imports: import argparse
  import os
  import sys
  import cv2
  import numpy
  import torch
  import tqdm
  from maskrcnn_benchmark.config import cfg
  from maskrcnn_benchmark.layers import nms
  from maskrcnn_benchmark.modeling.detector import build_detection_model
  from maskrcnn_benchmark.structures.image_list import to_image_list
  from maskrcnn_benchmark.utils.model_serialization import load_state_dict
  from PIL import Image
label_desc: Use image node_id 4 for calling a global function with example usage: extract_features(detection_model, image_path, input_boxes, feat_name) and returns: feat,  bbox