-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d8ed644
commit 6a629ca
Showing
84 changed files
with
20,014 additions
and
1 deletion.
There are no files selected for viewing
Submodule Real-time-Traffic-and-Pedestrian-Counting
deleted from
21e910
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# ================================================================ | ||
# Copyright (C) 2019 * Ltd. All rights reserved. | ||
# | ||
# Author : Clemente420 | ||
# Created date: 2019-11-14 | ||
# | ||
# ================================================================ | ||
|
||
import tensorflow as tf | ||
import core.common as common | ||
|
||
|
||
def darknet53(input_data): | ||
|
||
input_data = common.convolutional(input_data, (3, 3, 3, 32)) | ||
input_data = common.convolutional( | ||
input_data, (3, 3, 32, 64), downsample=True) | ||
|
||
for i in range(1): | ||
input_data = common.residual_block(input_data, 64, 32, 64) | ||
|
||
input_data = common.convolutional( | ||
input_data, (3, 3, 64, 128), downsample=True) | ||
|
||
for i in range(2): | ||
input_data = common.residual_block(input_data, 128, 64, 128) | ||
|
||
input_data = common.convolutional( | ||
input_data, (3, 3, 128, 256), downsample=True) | ||
|
||
for i in range(8): | ||
input_data = common.residual_block(input_data, 256, 128, 256) | ||
|
||
route_1 = input_data | ||
input_data = common.convolutional( | ||
input_data, (3, 3, 256, 512), downsample=True) | ||
|
||
for i in range(8): | ||
input_data = common.residual_block(input_data, 512, 256, 512) | ||
|
||
route_2 = input_data | ||
input_data = common.convolutional( | ||
input_data, (3, 3, 512, 1024), downsample=True) | ||
|
||
for i in range(4): | ||
input_data = common.residual_block(input_data, 1024, 512, 1024) | ||
|
||
return route_1, route_2, input_data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# ================================================================ | ||
# Copyright (C) 2019 * Ltd. All rights reserved. | ||
# | ||
# Author : Clemente420 | ||
# Created date: 2019-11-14 | ||
# | ||
# ================================================================ | ||
|
||
import tensorflow as tf | ||
|
||
|
||
class BatchNormalization(tf.keras.layers.BatchNormalization): | ||
""" | ||
"Frozen state" and "inference mode" are two separate concepts. | ||
`layer.trainable = False` is to freeze the layer, so the layer will use | ||
stored moving `var` and `mean` in the "inference mode", and both `gama` | ||
and `beta` will not be updated ! | ||
""" | ||
|
||
def call(self, x, training=False): | ||
if not training: | ||
training = tf.constant(False) | ||
training = tf.logical_and(training, self.trainable) | ||
return super().call(x, training) | ||
|
||
|
||
def convolutional(input_layer, filters_shape, downsample=False, activate=True, bn=True): | ||
if downsample: | ||
input_layer = tf.keras.layers.ZeroPadding2D( | ||
((1, 0), (1, 0)))(input_layer) | ||
padding = 'valid' | ||
strides = 2 | ||
else: | ||
strides = 1 | ||
padding = 'same' | ||
|
||
conv = tf.keras.layers.Conv2D(filters=filters_shape[-1], kernel_size=filters_shape[0], strides=strides, padding=padding, | ||
use_bias=not bn, kernel_regularizer=tf.keras.regularizers.l2(0.0005), | ||
kernel_initializer=tf.random_normal_initializer( | ||
stddev=0.01), | ||
bias_initializer=tf.constant_initializer(0.))(input_layer) | ||
|
||
if bn: | ||
conv = BatchNormalization()(conv) | ||
if activate == True: | ||
conv = tf.nn.leaky_relu(conv, alpha=0.1) | ||
|
||
return conv | ||
|
||
|
||
def residual_block(input_layer, input_channel, filter_num1, filter_num2): | ||
short_cut = input_layer | ||
conv = convolutional(input_layer, filters_shape=( | ||
1, 1, input_channel, filter_num1)) | ||
conv = convolutional(conv, filters_shape=( | ||
3, 3, filter_num1, filter_num2)) | ||
|
||
residual_output = short_cut + conv | ||
return residual_output | ||
|
||
|
||
def upsample(input_layer): | ||
return tf.image.resize(input_layer, (input_layer.shape[1] * 2, input_layer.shape[2] * 2), method='nearest') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# ================================================================ | ||
# Copyright (C) 2019 * Ltd. All rights reserved. | ||
# | ||
# Author : Clemente420 | ||
# Created date: 2019-11-14 | ||
# | ||
# ================================================================ | ||
|
||
from easydict import EasyDict as edict | ||
|
||
|
||
__C = edict() | ||
# Consumers can get config by: from config import cfg | ||
|
||
cfg = __C | ||
|
||
# YOLO options | ||
__C.YOLO = edict() | ||
|
||
# Set the class name | ||
__C.YOLO.CLASSES = "./data/classes/coco.names.back" | ||
__C.YOLO.ANCHORS = "./data/anchors/basline_anchors.txt" | ||
__C.YOLO.STRIDES = [8, 16, 32] | ||
__C.YOLO.ANCHOR_PER_SCALE = 3 | ||
__C.YOLO.IOU_LOSS_THRESH = 0.5 | ||
|
||
# Train options | ||
__C.TRAIN = edict() | ||
|
||
__C.TRAIN.ANNOT_PATH = "./data/dataset/yymnist_train.txt" | ||
__C.TRAIN.BATCH_SIZE = 4 | ||
# __C.TRAIN.INPUT_SIZE = [320, 352, 384, 416, 448, 480, 512, 544, 576, 608] | ||
__C.TRAIN.INPUT_SIZE = [416] | ||
__C.TRAIN.DATA_AUG = True | ||
__C.TRAIN.LR_INIT = 1e-3 | ||
__C.TRAIN.LR_END = 1e-6 | ||
__C.TRAIN.WARMUP_EPOCHS = 2 | ||
__C.TRAIN.EPOCHS = 30 | ||
|
||
|
||
|
||
# TEST options | ||
__C.TEST = edict() | ||
|
||
__C.TEST.ANNOT_PATH = "./data/dataset/yymnist_test.txt" | ||
__C.TEST.BATCH_SIZE = 2 | ||
__C.TEST.INPUT_SIZE = 544 | ||
__C.TEST.DATA_AUG = False | ||
__C.TEST.DECTECTED_IMAGE_PATH = "./data/detection/" | ||
__C.TEST.SCORE_THRESHOLD = 0.3 | ||
__C.TEST.IOU_THRESHOLD = 0.45 | ||
|
||
|
Oops, something went wrong.