From df7d876a554d05263f2f4b97fd8314e02f64a98b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B8=B0=ED=83=9D?= <33396317+samscientist@users.noreply.github.com> Date: Wed, 11 Sep 2024 00:13:23 +0900 Subject: [PATCH] fix bug - update 'deeplab.py' --- pixellib/semantic/deeplab.py | 40 ++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/pixellib/semantic/deeplab.py b/pixellib/semantic/deeplab.py index c41a175..0c0cd5a 100644 --- a/pixellib/semantic/deeplab.py +++ b/pixellib/semantic/deeplab.py @@ -4,22 +4,26 @@ import tensorflow as tf -from tensorflow.python.keras.models import Model -from tensorflow.python.keras import layers -from tensorflow.python.keras.layers import Input -from tensorflow.python.keras.layers import Lambda -from tensorflow.python.keras.layers import Activation -from tensorflow.python.keras.layers import Concatenate -from tensorflow.python.keras.layers import Add -from tensorflow.python.keras.layers import Dropout -from tensorflow.python.keras.layers import BatchNormalization -from tensorflow.python.keras.layers import Conv2D -from tensorflow.python.keras.layers import DepthwiseConv2D -from tensorflow.python.keras.layers import ZeroPadding2D -from tensorflow.python.keras.layers import GlobalAveragePooling2D +from tensorflow.keras.models import Model +from tensorflow.keras import layers +from tensorflow.keras.layers import Input +from tensorflow.keras.layers import Lambda +from tensorflow.keras.layers import Activation +from tensorflow.keras.layers import Concatenate +from tensorflow.keras.layers import Add +from tensorflow.keras.layers import Dropout +from tensorflow.keras.layers import BatchNormalization +from tensorflow.keras.layers import Conv2D +from tensorflow.keras.layers import DepthwiseConv2D +from tensorflow.keras.layers import ZeroPadding2D +from tensorflow.keras.layers import GlobalAveragePooling2D from tensorflow.python.keras.utils.layer_utils import get_source_inputs from tensorflow.keras import backend as K +class ShapeLayer(tf.keras.Layer): + def call(self, x): + return tf.shape(x) + config = tf.compat.v1.ConfigProto() config.gpu_options.allow_growth = True session = tf.compat.v1.InteractiveSession(config=config) @@ -196,10 +200,10 @@ def Deeplab_xcep_pascal(weights=None, input_tensor=None, input_shape=(512, 512, x = _xception_block(x, [1536, 1536, 2048], 'exit_flow_block2', skip_connection_type='none', stride=1, rate=exit_block_rates[1], depth_activation=True) - - - shape_before = tf.shape(x) + + + shape_before = ShapeLayer()(x) b4 = GlobalAveragePooling2D()(x) # from (b_size, channels)->(b_size, 1, 1, channels) b4 = Lambda(lambda x: K.expand_dims(x, 1))(b4) @@ -379,10 +383,10 @@ def Deeplab_xcep_ade20k(weights=None, input_tensor=None, input_shape=(512, 512, x = _xception_block(x, [1536, 1536, 2048], 'exit_flow_block2', skip_connection_type='none', stride=1, rate=exit_block_rates[1], depth_activation=True) + - - shape_before = tf.shape(x) + shape_before = ShapeLayer()(x) b4 = GlobalAveragePooling2D()(x) # from (b_size, channels)->(b_size, 1, 1, channels) b4 = Lambda(lambda x: K.expand_dims(x, 1))(b4)