-
Notifications
You must be signed in to change notification settings - Fork 4
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
0 parents
commit 132f15f
Showing
96 changed files
with
43,624 additions
and
0 deletions.
There are no files selected for viewing
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,2 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto |
Binary file not shown.
Binary file added
BIN
+6 KB
Convolutional Neural Networks/Car detection for Autonomous Driving/.DS_Store
Binary file not shown.
1,391 changes: 1,391 additions & 0 deletions
1,391
...g/.ipynb_checkpoints/Autonomous+driving+application+-+Car+detection+-+v3-checkpoint.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
1,391 changes: 1,391 additions & 0 deletions
1,391
...etection for Autonomous Driving/Autonomous+driving+application+-+Car+detection+-+v3.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file added
BIN
+6 KB
Convolutional Neural Networks/Car detection for Autonomous Driving/yad2k/.DS_Store
Binary file not shown.
71 changes: 71 additions & 0 deletions
71
...onal Neural Networks/Car detection for Autonomous Driving/yad2k/models/keras_darknet19.py
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,71 @@ | ||
"""Darknet19 Model Defined in Keras.""" | ||
import functools | ||
from functools import partial | ||
|
||
from keras.layers import Conv2D, MaxPooling2D | ||
from keras.layers.advanced_activations import LeakyReLU | ||
from keras.layers.normalization import BatchNormalization | ||
from keras.models import Model | ||
from keras.regularizers import l2 | ||
|
||
from ..utils import compose | ||
|
||
# Partial wrapper for Convolution2D with static default argument. | ||
_DarknetConv2D = partial(Conv2D, padding='same') | ||
|
||
|
||
@functools.wraps(Conv2D) | ||
def DarknetConv2D(*args, **kwargs): | ||
"""Wrapper to set Darknet weight regularizer for Convolution2D.""" | ||
darknet_conv_kwargs = {'kernel_regularizer': l2(5e-4)} | ||
darknet_conv_kwargs.update(kwargs) | ||
return _DarknetConv2D(*args, **darknet_conv_kwargs) | ||
|
||
|
||
def DarknetConv2D_BN_Leaky(*args, **kwargs): | ||
"""Darknet Convolution2D followed by BatchNormalization and LeakyReLU.""" | ||
no_bias_kwargs = {'use_bias': False} | ||
no_bias_kwargs.update(kwargs) | ||
return compose( | ||
DarknetConv2D(*args, **no_bias_kwargs), | ||
BatchNormalization(), | ||
LeakyReLU(alpha=0.1)) | ||
|
||
|
||
def bottleneck_block(outer_filters, bottleneck_filters): | ||
"""Bottleneck block of 3x3, 1x1, 3x3 convolutions.""" | ||
return compose( | ||
DarknetConv2D_BN_Leaky(outer_filters, (3, 3)), | ||
DarknetConv2D_BN_Leaky(bottleneck_filters, (1, 1)), | ||
DarknetConv2D_BN_Leaky(outer_filters, (3, 3))) | ||
|
||
|
||
def bottleneck_x2_block(outer_filters, bottleneck_filters): | ||
"""Bottleneck block of 3x3, 1x1, 3x3, 1x1, 3x3 convolutions.""" | ||
return compose( | ||
bottleneck_block(outer_filters, bottleneck_filters), | ||
DarknetConv2D_BN_Leaky(bottleneck_filters, (1, 1)), | ||
DarknetConv2D_BN_Leaky(outer_filters, (3, 3))) | ||
|
||
|
||
def darknet_body(): | ||
"""Generate first 18 conv layers of Darknet-19.""" | ||
return compose( | ||
DarknetConv2D_BN_Leaky(32, (3, 3)), | ||
MaxPooling2D(), | ||
DarknetConv2D_BN_Leaky(64, (3, 3)), | ||
MaxPooling2D(), | ||
bottleneck_block(128, 64), | ||
MaxPooling2D(), | ||
bottleneck_block(256, 128), | ||
MaxPooling2D(), | ||
bottleneck_x2_block(512, 256), | ||
MaxPooling2D(), | ||
bottleneck_x2_block(1024, 512)) | ||
|
||
|
||
def darknet19(inputs): | ||
"""Generate Darknet-19 model for Imagenet classification.""" | ||
body = darknet_body()(inputs) | ||
logits = DarknetConv2D(1000, (1, 1), activation='softmax')(body) | ||
return Model(inputs, logits) |
Oops, something went wrong.