code: def create_model(num_classes, load_pretrain_weights=True):
      # 如果GPU显存很小，batch_size不能设置很大，建议将norm_layer设置成FrozenBatchNorm2d(默认是nn.BatchNorm2d)
      # FrozenBatchNorm2d的功能与BatchNorm2d类似，但参数无法更新
      # trainable_layers包括['layer4', 'layer3', 'layer2', 'layer1', 'conv1']， 5代表全部训练
      # backbone = resnet50_fpn_backbone(norm_layer=FrozenBatchNorm2d,
      #                                  trainable_layers=3)
      # resnet50 imagenet weights url: https://download.pytorch.org/models/resnet50-0676ba61.pth
      backbone = resnet50_fpn_backbone(
          pretrain_path="resnet50.pth", trainable_layers=3
      )
  
      model = MaskRCNN(backbone, num_classes=num_classes)
  
      if load_pretrain_weights:
          # coco weights url: "https://download.pytorch.org/models/maskrcnn_resnet50_fpn_coco-bf2d0c1e.pth"
          weights_dict = torch.load(
              "./maskrcnn_resnet50_fpn_coco.pth", map_location="cpu"
          )
          for k in list(weights_dict.keys()):
              if ("box_predictor" in k) or ("mask_fcn_logits" in k):
                  del weights_dict[k]
  
          print(model.load_state_dict(weights_dict, strict=False))
  
      return model
  
file_path: deep-learning-for-image-processing/pytorch_object_detection/mask_rcnn/train.py
imports: import os
  import datetime
  import torch
  from torchvision.ops.misc import FrozenBatchNorm2d
  import transforms
  from network_files import MaskRCNN
  from backbone import resnet50_fpn_backbone
  from my_dataset_coco import CocoDetection
  from my_dataset_voc import VOCInstances
  from train_utils import train_eval_utils
  from train_utils import GroupedBatchSampler, create_aspect_ratio_groups
label_desc: Use image node_id 1 for calling a global function with example usage: create_model(num_classes, load_pretrain_weights) and returns: model