sudo-paras-shah commited on
Commit
04e599a
·
1 Parent(s): 95f47a6

Replace keras with tf.keras

Browse files
src/nets/Loss.py CHANGED
@@ -1,6 +1,6 @@
1
  import os
2
- from keras import backend as K
3
  import tensorflow as tf
 
4
  import numpy as np
5
 
6
  def multi_category_focal_loss2(gamma=2., alpha=1):
 
1
  import os
 
2
  import tensorflow as tf
3
+ from tf.keras import backend as K
4
  import numpy as np
5
 
6
  def multi_category_focal_loss2(gamma=2., alpha=1):
src/nets/mobilenet.py CHANGED
@@ -1,8 +1,8 @@
1
- from keras import backend as K
2
- from keras.layers import (Activation, BatchNormalization, Conv2D,
3
  DepthwiseConv2D, Dropout, GlobalAveragePooling2D,
4
  Input, Reshape)
5
- from keras.models import Model
6
 
7
 
8
  def _conv_block(inputs, filters, alpha, kernel=(3, 3), strides=(1, 1)):
 
1
+ from tensorflow.keras import backend as K
2
+ from tensorflow.keras.layers import (Activation, BatchNormalization, Conv2D,
3
  DepthwiseConv2D, Dropout, GlobalAveragePooling2D,
4
  Input, Reshape)
5
+ from tensorflow.keras.models import Model
6
 
7
 
8
  def _conv_block(inputs, filters, alpha, kernel=(3, 3), strides=(1, 1)):
src/nets/resnet50.py CHANGED
@@ -1,8 +1,8 @@
1
- from keras import layers
2
- from keras.layers import (Activation, AveragePooling2D, BatchNormalization,
3
  Conv2D, Dense, Flatten, Input, MaxPooling2D,
4
  ZeroPadding2D)
5
- from keras.models import Model
6
 
7
 
8
  def identity_block(input_tensor, kernel_size, filters, stage, block):
 
1
+ from tensorflow.keras import layers
2
+ from tensorflow.keras.layers import (Activation, AveragePooling2D, BatchNormalization,
3
  Conv2D, Dense, Flatten, Input, MaxPooling2D,
4
  ZeroPadding2D)
5
+ from tensorflow.keras.models import Model
6
 
7
 
8
  def identity_block(input_tensor, kernel_size, filters, stage, block):
src/nets/vgg16.py CHANGED
@@ -1,5 +1,5 @@
1
- from keras.layers import Conv2D, Dense, Flatten, Input, MaxPooling2D
2
- from keras.models import Model #导入包Conv2D是卷积核 Flatten是展开 Input输入 MaxPooling2D最大卷积核
3
 
4
 
5
  def VGG16(input_shape=None, classes=1000): #def 就是开始定义VGG16的网络
 
1
+ from tensorflow.keras.layers import Conv2D, Dense, Flatten, Input, MaxPooling2D
2
+ from tensorflow.keras.models import Model #导入包Conv2D是卷积核 Flatten是展开 Input输入 MaxPooling2D最大卷积核
3
 
4
 
5
  def VGG16(input_shape=None, classes=1000): #def 就是开始定义VGG16的网络
src/utils/callbacks.py CHANGED
@@ -1,6 +1,6 @@
1
  import os
2
 
3
- import keras
4
  import matplotlib
5
  matplotlib.use('Agg')
6
  from matplotlib import pyplot as plt
@@ -8,7 +8,7 @@ import scipy.signal
8
  import tensorflow as tf
9
 
10
 
11
- class LossHistory(keras.callbacks.Callback):
12
  def __init__(self, log_dir):
13
  import datetime
14
  curr_time = datetime.datetime.now()
@@ -60,7 +60,7 @@ class LossHistory(keras.callbacks.Callback):
60
  plt.cla()
61
  plt.close("all")
62
 
63
- class ExponentDecayScheduler(keras.callbacks.Callback):
64
  def __init__(self,
65
  decay_rate,
66
  verbose=0):
 
1
  import os
2
 
3
+ import tensorflow as tf
4
  import matplotlib
5
  matplotlib.use('Agg')
6
  from matplotlib import pyplot as plt
 
8
  import tensorflow as tf
9
 
10
 
11
+ class LossHistory(tf.keras.callbacks.Callback):
12
  def __init__(self, log_dir):
13
  import datetime
14
  curr_time = datetime.datetime.now()
 
60
  plt.cla()
61
  plt.close("all")
62
 
63
+ class ExponentDecayScheduler(tf.keras.callbacks.Callback):
64
  def __init__(self,
65
  decay_rate,
66
  verbose=0):
src/utils/dataloader.py CHANGED
@@ -2,15 +2,15 @@ import math
2
  from random import shuffle
3
 
4
  import cv2
5
- import keras
6
  import numpy as np
7
- from keras.utils import to_categorical
8
  from PIL import Image
9
 
10
  from .utils import cvtColor, preprocess_input
11
 
12
 
13
- class ClsDatasets(keras.utils.Sequence):
14
  def __init__(self, annotation_lines, input_shape, batch_size, num_classes, train, **kwargs):
15
  super().__init__()
16
  self.annotation_lines = annotation_lines
 
2
  from random import shuffle
3
 
4
  import cv2
5
+ import tensorflow as tf
6
  import numpy as np
7
+ from tf.keras.utils import to_categorical
8
  from PIL import Image
9
 
10
  from .utils import cvtColor, preprocess_input
11
 
12
 
13
+ class ClsDatasets(tf.keras.utils.Sequence):
14
  def __init__(self, annotation_lines, input_shape, batch_size, num_classes, train, **kwargs):
15
  super().__init__()
16
  self.annotation_lines = annotation_lines