Advertisement
Guest User

Configuration File Creator

a guest
Jun 17th, 2021
900
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.12 KB | None | 0 0
  1. with open('new_train_yaml', 'w+') as file:
  2.     file.write(
  3.         """
  4.        # parameters
  5.        nc: 1  # number of classes
  6.        depth_multiple: 0.33  # model depth multiple
  7.        width_multiple: 0.50  # layer channel multiple
  8.  
  9.        # anchors
  10.        anchors:
  11.          - [10,13, 16,30, 33,23]  # P3/8
  12.          - [30,61, 62,45, 59,119]  # P4/16
  13.          - [116,90, 156,198, 373,326]  # P5/32
  14.  
  15.        # YOLOv5 backbone
  16.        backbone:
  17.          # [from, number, module, args]
  18.          [[-1, 1, Focus, [64, 3]],  # 0-P1/2
  19.           [-1, 1, Conv, [128, 3, 2]],  # 1-P2/4
  20.           [-1, 3, BottleneckCSP, [128]],
  21.           [-1, 1, Conv, [256, 3, 2]],  # 3-P3/8
  22.           [-1, 9, BottleneckCSP, [256]],
  23.           [-1, 1, Conv, [512, 3, 2]],  # 5-P4/16
  24.           [-1, 9, BottleneckCSP, [512]],
  25.           [-1, 1, Conv, [1024, 3, 2]],  # 7-P5/32
  26.           [-1, 1, SPP, [1024, [5, 9, 13]]],
  27.           [-1, 3, BottleneckCSP, [1024, False]],  # 9
  28.          ]
  29.  
  30.        # YOLOv5 head
  31.        head:
  32.          [[-1, 1, Conv, [512, 1, 1]],
  33.           [-1, 1, nn.Upsample, [None, 2, 'nearest']],
  34.           [[-1, 6], 1, Concat, [1]],  # cat backbone P4
  35.           [-1, 3, BottleneckCSP, [512, False]],  # 13
  36.  
  37.           [-1, 1, Conv, [256, 1, 1]],
  38.           [-1, 1, nn.Upsample, [None, 2, 'nearest']],
  39.           [[-1, 4], 1, Concat, [1]],  # cat backbone P3
  40.           [-1, 3, BottleneckCSP, [256, False]],  # 17 (P3/8-small)
  41.  
  42.           [-1, 1, Conv, [256, 3, 2]],
  43.           [[-1, 14], 1, Concat, [1]],  # cat head P4
  44.           [-1, 3, BottleneckCSP, [512, False]],  # 20 (P4/16-medium)
  45.  
  46.           [-1, 1, Conv, [512, 3, 2]],
  47.           [[-1, 10], 1, Concat, [1]],  # cat head P5
  48.           [-1, 3, BottleneckCSP, [1024, False]],  # 23 (P5/32-large)
  49.  
  50.           [[17, 20, 23], 1, Detect, [nc, anchors]],  # Detect(P3, P4, P5)
  51.          ]
  52.        """
  53.     )
  54.  
  55. with open('new_data_yaml', 'w+') as file:
  56.     file.write(
  57.         """
  58.        train: /content/drive/MyDrive/data/images/train
  59.        val: /content/drive/MyDrive/data/images/valid
  60.  
  61.        nc: 1
  62.        names: ['Pistol']
  63.        """
  64.     )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement