code: def create_model(num_classes):
      # 如果显存很小，建议使用默认的FrozenBatchNorm2d
      # trainable_layers包括['layer4', 'layer3', 'layer2', 'layer1', 'conv1']， 5代表全部训练
      backbone = resnet50_fpn_backbone(
          norm_layer=torch.nn.BatchNorm2d, trainable_layers=3
      )
      # 训练自己数据集时不要修改这里的91，修改的是传入的num_classes参数
      model = FasterRCNN(backbone=backbone, num_classes=91)
      # 载入预训练模型权重
      # https://download.pytorch.org/models/fasterrcnn_resnet50_fpn_coco-258fb6c6.pth
      weights_dict = torch.load(
          "./backbone/fasterrcnn_resnet50_fpn_coco.pth",
          map_location="cpu",
      )
      missing_keys, unexpected_keys = model.load_state_dict(
          weights_dict, strict=False
      )
      if len(missing_keys) != 0 or len(unexpected_keys) != 0:
          print("missing_keys: ", missing_keys)
          print("unexpected_keys: ", unexpected_keys)
  
      # get number of input features for the classifier
      in_features = model.roi_heads.box_predictor.cls_score.in_features
      # replace the pre-trained head with a new one
      model.roi_heads.box_predictor = FastRCNNPredictor(
          in_features, num_classes
      )
  
      return model
  
file_path: deep-learning-for-image-processing/pytorch_object_detection/faster_rcnn/train_multi_GPU.py
imports: import time
  import os
  import datetime
  import torch
  import transforms
  from my_dataset import VOCDataSet
  from backbone import resnet50_fpn_backbone
  from network_files import FasterRCNN, FastRCNNPredictor
  import train_utils.train_eval_utils
  from train_utils import GroupedBatchSampler, create_aspect_ratio_groups, init_distributed_mode, save_on_master, mkdir
label_desc: Use image node_id 1 for calling a global function with example usage: create_model(num_classes) and returns: model