-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.py
97 lines (82 loc) · 2.53 KB
/
config.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
"""Config setup architecture"""
import json
class BaseConfig:
def __init__(self, **kwargs):
self.__dict__.update(kwargs)
def _to_dict(self):
values = [name for name in dir(self) if not name.startswith('_')]
return {name: self.__getattribute__(name) for name in values}
def __repr__(self):
# TODO Better representation of config (?)
print_params = json.dumps(self._to_dict(), indent=4)
string = f'{type(self).__name__}:\n{print_params}'
return string
class ImagesConfig(BaseConfig):
in_channels = 5
num_classes = 2 # galaxy + background
img_resolution = (128, 128)
img_after_resize = (256, 256)
class BackboneConfig(BaseConfig):
name = "resnet50"
input_channels = 5
class RPNConfig(BaseConfig):
anchor_sizes = ((2,), (4,), (8,), (16,), (32,))
aspect_ratios = ((0.5, 1.0, 2.0),) * len(anchor_sizes)
pre_nms_top_n_train = 200
pre_nms_top_n_test = 100
post_nms_top_n_train = 160
post_nms_top_n_test = 80
nms_thresh = 0.7
fg_iou_thresh = 0.7
bg_iou_thresh = 0.3
batch_size_per_image = 48
positive_fraction = 0.5
score_thresh = 0.0
class ROIBoxHeadConfig(BaseConfig):
output_pool_size = 7
score_thresh = 0.05
nms_thresh = 0.5
detections_per_img = 24
fg_iou_thresh = 0.5
bg_iou_thresh = 0.5
batch_size_per_image = 24
positive_fraction = 0.25
bbox_reg_weights = None
# TODO FIX
class EllipseConfig(BaseConfig):
pass
# # TODO FIX
# class MetaConfig():
# def __init__(
# self,
# images = ImagesConfig,
# backbone = BackboneConfig,
# rpn = RPNConfig,
# box = BoxConfig,
# ellipse = EllipseConfig
# ):
# self.images = images()
# self.backbone = backbone()
# self.rpn = rpn()
# self.ellipse = ellipse()
#
# def __repr__(self):
# return f'{self.images}\n\n{self.backbone}\n\n{self.rpn}\n\n{self.ellipse}'
#
# def to_json(self, path):
#
# dictionary = {key: self.__dict__[key].__dic for key in self.__dict__}
# #json_object = json.dumps(, indent=4)
# with open(path, "w") as f:
# f.write(json_object)
#
# def from_json(self):
# pass
# # @classmethod
# # def from_dict(cls, the_dict) -> PlotConfig:
# # """Create a PlotConfig object from a dict"""
# # return cls(
# # plotname=the_dict["plotname"],
# # classname=the_dict["classname"],
# # plot_config=the_dict["plot_config"],
# # )