RashiAgarwal commited on
Commit
fba5215
1 Parent(s): 25fffe1

Upload config.py

Browse files
Files changed (1) hide show
  1. config.py +187 -0
config.py ADDED
@@ -0,0 +1,187 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import albumentations as A
2
+ import cv2
3
+ import torch
4
+
5
+ from albumentations.pytorch import ToTensorV2
6
+ from utils import seed_everything
7
+
8
+ DATASET = '/content/PASCAL_VOC'
9
+ DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
10
+ # seed_everything() # If you want deterministic behavior
11
+ NUM_WORKERS = 2
12
+ BATCH_SIZE = 32
13
+ IMAGE_SIZE = 416
14
+ NUM_CLASSES = 20
15
+ LEARNING_RATE = 1e-3
16
+ WEIGHT_DECAY = 1e-4
17
+ NUM_EPOCHS = 40
18
+ CONF_THRESHOLD = 0.05
19
+ MAP_IOU_THRESH = 0.5
20
+ NMS_IOU_THRESH = 0.45
21
+ S = [IMAGE_SIZE // 32, IMAGE_SIZE // 16, IMAGE_SIZE // 8]
22
+ PIN_MEMORY = True
23
+ LOAD_MODEL = False
24
+ SAVE_MODEL = True
25
+ CHECKPOINT_FILE = "checkpoint.pth.tar"
26
+ IMG_DIR = DATASET + "/images/"
27
+ LABEL_DIR = DATASET + "/labels/"
28
+
29
+ ANCHORS = [
30
+ [(0.28, 0.22), (0.38, 0.48), (0.9, 0.78)],
31
+ [(0.07, 0.15), (0.15, 0.11), (0.14, 0.29)],
32
+ [(0.02, 0.03), (0.04, 0.07), (0.08, 0.06)],
33
+ ] # Note these have been rescaled to be between [0, 1]
34
+
35
+ SCALED_ANCHORS = (
36
+ torch.tensor(ANCHORS) * torch.tensor(S).unsqueeze(1).unsqueeze(1).repeat(1, 3, 2)
37
+ ).to(device="cuda")
38
+ means = [0.485, 0.456, 0.406]
39
+
40
+ scale = 1.1
41
+ train_transforms = A.Compose(
42
+ [
43
+ A.LongestMaxSize(max_size=int(IMAGE_SIZE * scale)),
44
+ A.PadIfNeeded(
45
+ min_height=int(IMAGE_SIZE * scale),
46
+ min_width=int(IMAGE_SIZE * scale),
47
+ border_mode=cv2.BORDER_CONSTANT,
48
+ ),
49
+ A.Rotate(limit = 10, interpolation=1, border_mode=4),
50
+ A.RandomCrop(width=IMAGE_SIZE, height=IMAGE_SIZE),
51
+ A.ColorJitter(brightness=0.6, contrast=0.6, saturation=0.6, hue=0.6, p=0.4),
52
+ A.OneOf(
53
+ [
54
+ A.ShiftScaleRotate(
55
+ rotate_limit=20, p=0.5, border_mode=cv2.BORDER_CONSTANT
56
+ ),
57
+ # A.Affine(shear=15, p=0.5, mode="constant"),
58
+ ],
59
+ p=1.0,
60
+ ),
61
+ A.HorizontalFlip(p=0.5),
62
+ A.Blur(p=0.1),
63
+ A.CLAHE(p=0.1),
64
+ A.Posterize(p=0.1),
65
+ A.ToGray(p=0.1),
66
+ A.ChannelShuffle(p=0.05),
67
+ A.Normalize(mean=[0, 0, 0], std=[1, 1, 1], max_pixel_value=255,),
68
+ ToTensorV2(),
69
+ ],
70
+ bbox_params=A.BboxParams(format="yolo", min_visibility=0.4, label_fields=[],),
71
+ )
72
+ test_transforms = A.Compose(
73
+ [
74
+ A.LongestMaxSize(max_size=IMAGE_SIZE),
75
+ A.PadIfNeeded(
76
+ min_height=IMAGE_SIZE, min_width=IMAGE_SIZE, border_mode=cv2.BORDER_CONSTANT
77
+ ),
78
+ A.Normalize(mean=[0, 0, 0], std=[1, 1, 1], max_pixel_value=255,),
79
+ ToTensorV2(),
80
+ ],
81
+ bbox_params=A.BboxParams(format="yolo", min_visibility=0.4, label_fields=[]),
82
+ )
83
+
84
+ PASCAL_CLASSES = [
85
+ "aeroplane",
86
+ "bicycle",
87
+ "bird",
88
+ "boat",
89
+ "bottle",
90
+ "bus",
91
+ "car",
92
+ "cat",
93
+ "chair",
94
+ "cow",
95
+ "diningtable",
96
+ "dog",
97
+ "horse",
98
+ "motorbike",
99
+ "person",
100
+ "pottedplant",
101
+ "sheep",
102
+ "sofa",
103
+ "train",
104
+ "tvmonitor"
105
+ ]
106
+
107
+ COCO_LABELS = ['person',
108
+ 'bicycle',
109
+ 'car',
110
+ 'motorcycle',
111
+ 'airplane',
112
+ 'bus',
113
+ 'train',
114
+ 'truck',
115
+ 'boat',
116
+ 'traffic light',
117
+ 'fire hydrant',
118
+ 'stop sign',
119
+ 'parking meter',
120
+ 'bench',
121
+ 'bird',
122
+ 'cat',
123
+ 'dog',
124
+ 'horse',
125
+ 'sheep',
126
+ 'cow',
127
+ 'elephant',
128
+ 'bear',
129
+ 'zebra',
130
+ 'giraffe',
131
+ 'backpack',
132
+ 'umbrella',
133
+ 'handbag',
134
+ 'tie',
135
+ 'suitcase',
136
+ 'frisbee',
137
+ 'skis',
138
+ 'snowboard',
139
+ 'sports ball',
140
+ 'kite',
141
+ 'baseball bat',
142
+ 'baseball glove',
143
+ 'skateboard',
144
+ 'surfboard',
145
+ 'tennis racket',
146
+ 'bottle',
147
+ 'wine glass',
148
+ 'cup',
149
+ 'fork',
150
+ 'knife',
151
+ 'spoon',
152
+ 'bowl',
153
+ 'banana',
154
+ 'apple',
155
+ 'sandwich',
156
+ 'orange',
157
+ 'broccoli',
158
+ 'carrot',
159
+ 'hot dog',
160
+ 'pizza',
161
+ 'donut',
162
+ 'cake',
163
+ 'chair',
164
+ 'couch',
165
+ 'potted plant',
166
+ 'bed',
167
+ 'dining table',
168
+ 'toilet',
169
+ 'tv',
170
+ 'laptop',
171
+ 'mouse',
172
+ 'remote',
173
+ 'keyboard',
174
+ 'cell phone',
175
+ 'microwave',
176
+ 'oven',
177
+ 'toaster',
178
+ 'sink',
179
+ 'refrigerator',
180
+ 'book',
181
+ 'clock',
182
+ 'vase',
183
+ 'scissors',
184
+ 'teddy bear',
185
+ 'hair drier',
186
+ 'toothbrush'
187
+ ]