-
Notifications
You must be signed in to change notification settings - Fork 0
/
constants.py
123 lines (112 loc) · 3.4 KB
/
constants.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
import pandas as pd
import torch
import os
'''
Constants
'''
colab = os.path.isdir("drive")
if colab:
IMAGES_PATH = "data/train"
DATA_PATH = "data/train.csv"
METADATA_PATH = "data/train_meta.csv"
EMBEDDED_METADATA_PATH = "data/embedded_metadata.csv"
CHECKPOINT_PATH = "drive/MyDrive/object_detection_project/checkpoints"
TRAIN_IMAGES = "drive/MyDrive/object_detection_project/train_images.txt"
TEST_IMAGES = "drive/MyDrive/object_detection_project/test_images.txt"
TRAIN_IMAGES_WE = "drive/MyDrive/object_detection_project/train_images_we.txt"
TEST_IMAGES_WE = "drive/MyDrive/object_detection_project/test_images_we.txt"
SAVED_MODELS = "drive/MyDrive/object_detection_project/checkpoints"
else:
IMAGES_PATH = "./data/train"
DATA_PATH = "./data/train.csv"
METADATA_PATH = "./data/train_meta.csv"
EMBEDDED_METADATA_PATH = "data/embedded_metadata.csv"
CHECKPOINT_PATH = "./checkpoints"
TRAIN_IMAGES = "./data/train_images.txt"
TEST_IMAGES = "./data/test_images.txt"
TRAIN_IMAGES_WE = "./data/train_images_we.txt"
TEST_IMAGES_WE = "./data/test_images_we.txt"
SAVED_MODELS = "checkpoints"
# The classes used fo the model
CLASSES = [
"Background",
"Aortic enlargement",
"Cardiomegaly",
"Pleural thickening",
"Pulmonary fibrosis",
]
n_classes = len(CLASSES)
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
# Original data - contains image ids and annotated objects
train_data = pd.read_csv(DATA_PATH)
# Original size of each image
train_metadata = pd.read_csv(METADATA_PATH)
# Data with bounding boxes rescaled and transformed to a [x_center, y_center, width, height] format
embedded_metadata = (
pd.read_csv(EMBEDDED_METADATA_PATH)
if os.path.isfile(EMBEDDED_METADATA_PATH)
else None
)
# Different configuration of priors
priors_config = [
{
"fmap_dims": {
"conv4_3": 32,
"conv7": 16,
"conv8_2": 8,
"conv9_2": 4,
"conv10_2": 2,
},
"obj_scales": {
"conv4_3": 0.1,
"conv7": 0.2,
"conv8_2": 0.375,
"conv9_2": 0.55,
"conv10_2": 0.725,
},
"aspect_ratios": {
"conv4_3": [1.0, 2.0, 0.5],
"conv7": [1.0, 2.0, 3.0, 0.5, 0.333],
"conv8_2": [1.0, 2.0, 3.0, 0.5, 0.333],
"conv9_2": [1.0, 2.0, 3.0, 0.5, 0.333],
"conv10_2": [1.0, 2.0, 0.5],
},
"n_boxes": {
"conv4_3": 4,
"conv7": 6,
"conv8_2": 6,
"conv9_2": 6,
"conv10_2": 4,
},
},
{
"fmap_dims": {
"conv4_3": 32,
"conv7": 16,
"conv8_2": 8,
"conv9_2": 4,
"conv10_2": 2,
},
"obj_scales": {
"conv4_3": 0.05,
"conv7": 0.2,
"conv8_2": 0.375,
"conv9_2": 0.55,
"conv10_2": 0.725,
},
"aspect_ratios": {
"conv4_3": [1.0, 2.0, 3.0, 0.5, 0.333],
"conv7": [1.0, 2.0, 3.0, 0.5, 0.333],
"conv8_2": [1.0, 2.0, 3.0, 0.5, 0.333],
"conv9_2": [1.0, 2.0, 3.0, 0.5, 0.333],
"conv10_2": [1.0, 2.0, 0.5],
},
"n_boxes": {
"conv4_3": 6,
"conv7": 6,
"conv8_2": 6,
"conv9_2": 6,
"conv10_2": 4,
},
},
]