-
Notifications
You must be signed in to change notification settings - Fork 11
/
Darknet53.py
executable file
·94 lines (83 loc) · 3.76 KB
/
Darknet53.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
# ==============================================================================
# MIT License
#
# Copyright 2021 Institute for Automotive Engineering of RWTH Aachen University.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# ==============================================================================
"""Model configuration for Darknet52"""
import numpy as np
from easydict import EasyDict
def Darknet53():
mc = EasyDict()
mc.CLASSES = ['Road',
'Sidewalk',
'Building',
'Pole',
'Vegetation',
'Person',
'TwoWheeler',
'Car',
'Truck',
'Bus',
"None"]
mc.NUM_CLASS = len(mc.CLASSES)
mc.CLS_2_ID = dict(zip(mc.CLASSES, range(len(mc.CLASSES))))
mc.CLS_LOSS_WEIGHT = np.array([1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0])
mc.CLS_COLOR_MAP = np.array([[128, 64, 128], # Road
[244, 35, 232], # Sidewalk
[ 70, 70, 70], # Building
[153, 153, 153], # Pole
[107, 142, 35], # Vegetation
[220, 20, 60], # Person
[255, 0, 0], # Two Wheeler
[ 0, 0, 142], # Car
[ 0, 0, 70], # Truck
[ 0, 60, 100], # Bus
[ 0, 0, 0] # None
]) / 255.0
# Input Shape
mc.BATCH_SIZE = 16
mc.AZIMUTH_LEVEL = 240
mc.ZENITH_LEVEL = 32
mc.NUM_FEATURES = 6
# Loss
mc.USE_FOCAL_LOSS = False # either use focal loss or sparse categorical cross entropy
mc.FOCAL_GAMMA = 2.0
mc.CLS_LOSS_COEF = 15.0
mc.DENOM_EPSILON = 1e-12 # small value used in denominator to prevent division by 0
# Gradient Decent
mc.LEARNING_RATE = 0.005
mc.LR_DECAY_STEPS = 500
mc.LR_DECAY_FACTOR = 0.99
mc.MAX_GRAD_NORM = 1.0
# Network
mc.DROP_RATE = 0.01
mc.BN_MOMENTUM = 0.9
mc.NUM_LAYERS = 53
mc.OUTPUT_STRIDE = 16 # Output stride only horizontally
# Dataset
mc.DATA_AUGMENTATION = True
mc.RANDOM_FLIPPING = True
mc.SHIFT_UP_DOWN = 0
mc.SHIFT_LEFT_RIGHT = 70
# x, y, z, intensity, distance
mc.INPUT_MEAN = np.array([[[24.810, 0.819, 0.000, 16.303, 25.436]]])
mc.INPUT_STD = np.array([[[30.335, 7.807, 2.058, 25.208, 30.897]]])
return mc