Spaces:
Runtime error
Runtime error
update tf version
Browse files- InstanceNorm.py +4 -3
- models.py +6 -6
- requirements.txt +6 -6
InstanceNorm.py
CHANGED
@@ -1,7 +1,8 @@
|
|
1 |
-
from keras.engine import Layer
|
|
|
2 |
from keras import initializers, regularizers, constraints
|
3 |
from keras import backend as K
|
4 |
-
from keras.
|
5 |
|
6 |
import tensorflow as tf
|
7 |
|
@@ -110,7 +111,7 @@ class InstanceNormalization(Layer):
|
|
110 |
|
111 |
del reduction_axes[0]
|
112 |
|
113 |
-
mean, var = tf.nn.moments(inputs, reduction_axes,
|
114 |
stddev = tf.sqrt(var) + self.epsilon
|
115 |
normed = (inputs - mean) / stddev
|
116 |
|
|
|
1 |
+
from keras.engine.base_layer import Layer
|
2 |
+
from keras.engine.input_spec import InputSpec
|
3 |
from keras import initializers, regularizers, constraints
|
4 |
from keras import backend as K
|
5 |
+
from keras.saving.object_registration import get_custom_objects
|
6 |
|
7 |
import tensorflow as tf
|
8 |
|
|
|
111 |
|
112 |
del reduction_axes[0]
|
113 |
|
114 |
+
mean, var = tf.nn.moments(inputs, reduction_axes, keepdims=True)
|
115 |
stddev = tf.sqrt(var) + self.epsilon
|
116 |
normed = (inputs - mean) / stddev
|
117 |
|
models.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
from keras.layers import Conv2D, Activation, Input, Concatenate, LeakyReLU, Lambda, AveragePooling2D, UpSampling2D, Convolution2D, BatchNormalization,
|
2 |
from keras.models import Model
|
3 |
from InstanceNorm import InstanceNormalization
|
4 |
|
@@ -31,13 +31,13 @@ def make_standard_UNET(channels,outs):
|
|
31 |
bnc7 = BatchNormalization(axis=3, name='bnc7')
|
32 |
bnc8 = BatchNormalization(axis=3, name='bnc8')
|
33 |
|
34 |
-
dc8 =
|
35 |
dc7 = Convolution2D(filters=256, kernel_size=3, strides=1, padding='same', name='dc7')
|
36 |
-
dc6 =
|
37 |
dc5 = Convolution2D(filters=128, kernel_size=3, strides=1, padding='same', name='dc5')
|
38 |
-
dc4 =
|
39 |
dc3 = Convolution2D(filters=64, kernel_size=3, strides=1, padding='same', name='dc3')
|
40 |
-
dc2 =
|
41 |
dc1 = Convolution2D(filters=32, kernel_size=3, strides=1, padding='same', name='dc1')
|
42 |
dc0 = Convolution2D(filters=outs, kernel_size=3, strides=1, padding='same', name='dc0')
|
43 |
|
@@ -212,7 +212,7 @@ def make_unet512():
|
|
212 |
return Conv2D(filters=filters, strides=strides, kernel_size=kernel_size, padding='same')(x)
|
213 |
|
214 |
def donv(x, filters, strides=(2, 2), kernel_size=(4, 4)):
|
215 |
-
return
|
216 |
|
217 |
def relu(x):
|
218 |
return Activation('relu')(x)
|
|
|
1 |
+
from keras.layers import Conv2D, Activation, Input, Concatenate, LeakyReLU, Lambda, AveragePooling2D, UpSampling2D, Convolution2D, BatchNormalization, Conv2DTranspose, Add
|
2 |
from keras.models import Model
|
3 |
from InstanceNorm import InstanceNormalization
|
4 |
|
|
|
31 |
bnc7 = BatchNormalization(axis=3, name='bnc7')
|
32 |
bnc8 = BatchNormalization(axis=3, name='bnc8')
|
33 |
|
34 |
+
dc8 = Conv2DTranspose(filters=512, kernel_size=4, strides=2, padding='same', name='dc8_')
|
35 |
dc7 = Convolution2D(filters=256, kernel_size=3, strides=1, padding='same', name='dc7')
|
36 |
+
dc6 = Conv2DTranspose(filters=256, kernel_size=4, strides=2, padding='same', name='dc6_')
|
37 |
dc5 = Convolution2D(filters=128, kernel_size=3, strides=1, padding='same', name='dc5')
|
38 |
+
dc4 = Conv2DTranspose(filters=128, kernel_size=4, strides=2, padding='same', name='dc4_')
|
39 |
dc3 = Convolution2D(filters=64, kernel_size=3, strides=1, padding='same', name='dc3')
|
40 |
+
dc2 = Conv2DTranspose(filters=64, kernel_size=4, strides=2, padding='same', name='dc2_')
|
41 |
dc1 = Convolution2D(filters=32, kernel_size=3, strides=1, padding='same', name='dc1')
|
42 |
dc0 = Convolution2D(filters=outs, kernel_size=3, strides=1, padding='same', name='dc0')
|
43 |
|
|
|
212 |
return Conv2D(filters=filters, strides=strides, kernel_size=kernel_size, padding='same')(x)
|
213 |
|
214 |
def donv(x, filters, strides=(2, 2), kernel_size=(4, 4)):
|
215 |
+
return Conv2DTranspose(filters=filters, strides=strides, kernel_size=kernel_size, padding='same')(x)
|
216 |
|
217 |
def relu(x):
|
218 |
return Activation('relu')(x)
|
requirements.txt
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
opencv-contrib-python>=4.1.0.25
|
2 |
-
|
3 |
gradio>=3.20.1
|
4 |
-
keras
|
5 |
-
scikit-learn
|
6 |
-
scikit-image
|
7 |
-
llvmlite
|
8 |
-
numba
|
9 |
tqdm
|
10 |
paste
|
11 |
|
|
|
1 |
opencv-contrib-python>=4.1.0.25
|
2 |
+
tensorflow>=2.12.0
|
3 |
gradio>=3.20.1
|
4 |
+
keras>=2.2.5
|
5 |
+
scikit-learn>=0.23.1
|
6 |
+
scikit-image>=0.14.5
|
7 |
+
llvmlite>=0.36.0
|
8 |
+
numba>=0.53.1
|
9 |
tqdm
|
10 |
paste
|
11 |
|