Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified LICENSE
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
Empty file.
1 change: 1 addition & 0 deletions _config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
theme: jekyll-theme-cayman
10 changes: 5 additions & 5 deletions keras_frcnn/FixedBatchNormalization.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@ def __init__(self, epsilon=1e-3, axis=-1,

def build(self, input_shape):
self.input_spec = [InputSpec(shape=input_shape)]
shape = (input_shape[self.axis],)
shape_= (input_shape[self.axis],)

self.gamma = self.add_weight(shape,
self.gamma = self.add_weight(shape=shape_,
initializer=self.gamma_init,
regularizer=self.gamma_regularizer,
name='{}_gamma'.format(self.name),
trainable=False)
self.beta = self.add_weight(shape,
self.beta = self.add_weight(shape=shape_,
initializer=self.beta_init,
regularizer=self.beta_regularizer,
name='{}_beta'.format(self.name),
trainable=False)
self.running_mean = self.add_weight(shape, initializer='zero',
self.running_mean = self.add_weight(shape=shape_, initializer='zero',
name='{}_running_mean'.format(self.name),
trainable=False)
self.running_std = self.add_weight(shape, initializer='one',
self.running_std = self.add_weight(shape=shape_, initializer='one',
name='{}_running_std'.format(self.name),
trainable=False)

Expand Down
4 changes: 2 additions & 2 deletions keras_frcnn/RoiPoolingConv.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class RoiPoolingConv(Layer):
'''
def __init__(self, pool_size, num_rois, **kwargs):

self.dim_ordering = K.image_dim_ordering()
self.dim_ordering = K.common.image_dim_ordering()
assert self.dim_ordering in {'tf', 'th'}, 'dim_ordering must be in {tf, th}'

self.pool_size = pool_size
Expand Down Expand Up @@ -102,7 +102,7 @@ def call(self, x, mask=None):
w = K.cast(w, 'int32')
h = K.cast(h, 'int32')

rs = tf.image.resize_images(img[:, y:y+h, x:x+w, :], (self.pool_size, self.pool_size))
rs = tf.image.resize(img[:, y:y+h, x:x+w, :], (self.pool_size, self.pool_size))
outputs.append(rs)

final_output = K.concatenate(outputs, axis=0)
Expand Down
Empty file modified keras_frcnn/__init__.py
100644 → 100755
Empty file.
Empty file modified keras_frcnn/config.py
100644 → 100755
Empty file.
Empty file modified keras_frcnn/data_augment.py
100644 → 100755
Empty file.
Empty file modified keras_frcnn/data_generators.py
100644 → 100755
Empty file.
6 changes: 3 additions & 3 deletions keras_frcnn/losses.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from keras import backend as K
from keras.objectives import categorical_crossentropy

if K.image_dim_ordering() == 'tf':
if K.common.image_dim_ordering() == 'tf':
import tensorflow as tf

lambda_rpn_regr = 1.0
Expand All @@ -15,7 +15,7 @@

def rpn_loss_regr(num_anchors):
def rpn_loss_regr_fixed_num(y_true, y_pred):
if K.image_dim_ordering() == 'th':
if K.common.image_dim_ordering() == 'th':
x = y_true[:, 4 * num_anchors:, :, :] - y_pred
x_abs = K.abs(x)
x_bool = K.less_equal(x_abs, 1.0)
Expand All @@ -34,7 +34,7 @@ def rpn_loss_regr_fixed_num(y_true, y_pred):

def rpn_loss_cls(num_anchors):
def rpn_loss_cls_fixed_num(y_true, y_pred):
if K.image_dim_ordering() == 'tf':
if K.common.image_dim_ordering() == 'tf':
return lambda_rpn_class * K.sum(y_true[:, :, :, :num_anchors] * K.binary_crossentropy(y_pred[:, :, :, :], y_true[:, :, :, num_anchors:])) / K.sum(epsilon + y_true[:, :, :, :num_anchors])
else:
return lambda_rpn_class * K.sum(y_true[:, :num_anchors, :, :] * K.binary_crossentropy(y_pred[:, :, :, :], y_true[:, num_anchors:, :, :])) / K.sum(epsilon + y_true[:, :num_anchors, :, :])
Expand Down
Empty file modified keras_frcnn/pascal_voc_parser.py
100644 → 100755
Empty file.
14 changes: 7 additions & 7 deletions keras_frcnn/resnet.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from keras_frcnn.FixedBatchNormalization import FixedBatchNormalization

def get_weight_path():
if K.image_dim_ordering() == 'th':
if K.common.image_dim_ordering() == 'th':
return 'resnet50_weights_th_dim_ordering_th_kernels_notop.h5'
else:
return 'resnet50_weights_tf_dim_ordering_tf_kernels.h5'
Expand All @@ -39,7 +39,7 @@ def identity_block(input_tensor, kernel_size, filters, stage, block, trainable=T

nb_filter1, nb_filter2, nb_filter3 = filters

if K.image_dim_ordering() == 'tf':
if K.common.image_dim_ordering() == 'tf':
bn_axis = 3
else:
bn_axis = 1
Expand Down Expand Up @@ -68,7 +68,7 @@ def identity_block_td(input_tensor, kernel_size, filters, stage, block, trainabl
# identity block time distributed

nb_filter1, nb_filter2, nb_filter3 = filters
if K.image_dim_ordering() == 'tf':
if K.common.image_dim_ordering() == 'tf':
bn_axis = 3
else:
bn_axis = 1
Expand All @@ -95,7 +95,7 @@ def identity_block_td(input_tensor, kernel_size, filters, stage, block, trainabl
def conv_block(input_tensor, kernel_size, filters, stage, block, strides=(2, 2), trainable=True):

nb_filter1, nb_filter2, nb_filter3 = filters
if K.image_dim_ordering() == 'tf':
if K.common.image_dim_ordering() == 'tf':
bn_axis = 3
else:
bn_axis = 1
Expand Down Expand Up @@ -127,7 +127,7 @@ def conv_block_td(input_tensor, kernel_size, filters, stage, block, input_shape,
# conv block time distributed

nb_filter1, nb_filter2, nb_filter3 = filters
if K.image_dim_ordering() == 'tf':
if K.common.image_dim_ordering() == 'tf':
bn_axis = 3
else:
bn_axis = 1
Expand Down Expand Up @@ -156,7 +156,7 @@ def conv_block_td(input_tensor, kernel_size, filters, stage, block, input_shape,
def nn_base(input_tensor=None, trainable=False):

# Determine proper input shape
if K.image_dim_ordering() == 'th':
if K.common.image_dim_ordering() == 'th':
input_shape = (3, None, None)
else:
input_shape = (None, None, 3)
Expand All @@ -169,7 +169,7 @@ def nn_base(input_tensor=None, trainable=False):
else:
img_input = input_tensor

if K.image_dim_ordering() == 'tf':
if K.common.image_dim_ordering() == 'tf':
bn_axis = 3
else:
bn_axis = 1
Expand Down
Empty file modified keras_frcnn/roi_helpers.py
100644 → 100755
Empty file.
Empty file modified keras_frcnn/simple_parser.py
100644 → 100755
Empty file.
Empty file modified keras_frcnn/vgg.py
100644 → 100755
Empty file.
Empty file modified measure_map.py
100644 → 100755
Empty file.
Empty file modified requirements.txt
100644 → 100755
Empty file.
Empty file modified test_frcnn.py
100644 → 100755
Empty file.
8 changes: 4 additions & 4 deletions train_frcnn.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@
print('Num val samples {}'.format(len(val_imgs)))


data_gen_train = data_generators.get_anchor_gt(train_imgs, classes_count, C, nn.get_img_output_length, K.image_dim_ordering(), mode='train')
data_gen_val = data_generators.get_anchor_gt(val_imgs, classes_count, C, nn.get_img_output_length,K.image_dim_ordering(), mode='val')
data_gen_train = data_generators.get_anchor_gt(train_imgs, classes_count, C, nn.get_img_output_length, K.common.image_dim_ordering(), mode='train')
data_gen_val = data_generators.get_anchor_gt(val_imgs, classes_count, C, nn.get_img_output_length,K.common.image_dim_ordering(), mode='val')

if K.image_dim_ordering() == 'th':
if K.common.image_dim_ordering() == 'th':
input_shape_img = (3, None, None)
else:
input_shape_img = (None, None, 3)
Expand Down Expand Up @@ -184,7 +184,7 @@

P_rpn = model_rpn.predict_on_batch(X)

R = roi_helpers.rpn_to_roi(P_rpn[0], P_rpn[1], C, K.image_dim_ordering(), use_regr=True, overlap_thresh=0.7, max_boxes=300)
R = roi_helpers.rpn_to_roi(P_rpn[0], P_rpn[1], C, K.common.image_dim_ordering(), use_regr=True, overlap_thresh=0.7, max_boxes=300)
# note: calc_iou converts from (x1,y1,x2,y2) to (x,y,w,h) format
X2, Y1, Y2, IouS = roi_helpers.calc_iou(R, img_data, C, class_mapping)

Expand Down