faceswap-GAN icon indicating copy to clipboard operation
faceswap-GAN copied to clipboard

name 'regularizers' is not defined

Open L-KH opened this issue 5 years ago • 12 comments

//run ::: model = FaceswapGANModel(**arch_config)


NameError Traceback (most recent call last)

in () 1 from keras import regularizers ----> 2 model = FaceswapGANModel(**arch_config)

2 frames

/content/faceswap-GAN/networks/nn_blocks.py in conv_block(input_tensor, f, use_norm, strides, w_l2, norm) 126 def conv_block(input_tensor, f, use_norm=False, strides=2, w_l2=w_l2, norm='none'): 127 x = input_tensor --> 128 x = Conv2D(f, kernel_size=3, strides=strides, kernel_regularizer=regularizers.l2(w_l2),
129 kernel_initializer=conv_init, use_bias=False, padding="same")(x) 130 x = Activation("relu")(x)

NameError: name 'regularizers' is not defined

L-KH avatar Sep 04 '19 23:09 L-KH

Downgrading Keras will solve this issue.

shaoanlu avatar Sep 05 '19 02:09 shaoanlu

this issue is from colab in build the model part : https://colab.research.google.com/github/shaoanlu/faceswap-GAN/blob/master/colab_demo/faceswap-GAN_colab_demo.ipynb#scrollTo=yiNsc3N_2VhU

L-KH avatar Sep 05 '19 09:09 L-KH

I met the same bug, just need to add from keras import regularizers in the head of nn_blocks.py.

ok-sweat avatar Sep 09 '19 12:09 ok-sweat

I'm trying to run the colab notebook and running into this bug. Access denied to nn_blocks.py. Any suggestions?

AlasdairWalker avatar Oct 03 '19 18:10 AlasdairWalker

this issue is from colab in build the model part : https://colab.research.google.com/github/shaoanlu/faceswap-GAN/blob/master/colab_demo/faceswap-GAN_colab_demo.ipynb#scrollTo=yiNsc3N_2VhU

Did you find a solution to the issue in the colab notebook? Did "from keras import regularizers" in nn_blocks.py work?

Right now, i just don't know, what to do.

Mario2712 avatar Oct 14 '19 17:10 Mario2712

this issue is from colab in build the model part : https://colab.research.google.com/github/shaoanlu/faceswap-GAN/blob/master/colab_demo/faceswap-GAN_colab_demo.ipynb#scrollTo=yiNsc3N_2VhU

Did you find a solution to the issue in the colab notebook? Did "from keras import regularizers" in nn_blocks.py work?

Right now, i just don't know, what to do.

Yeah, I used that coda and it works

ok-sweat avatar Oct 15 '19 08:10 ok-sweat

i have the same problem but the solution proposed not work..or i have to start all over again?(like import videos ecc?)

Alkatraz91 avatar Dec 07 '19 15:12 Alkatraz91

@L-KH @shaoanlu @ok-sweat @AlasdairWalker @Mario2712

I have the same issue while trying to run the code on colab for model = FaceswapGANModel(**arch_config) can anybody please assist

NameError Traceback (most recent call last) in () ----> 1 model = FaceswapGANModel(**arch_config)

2 frames /content/faceswap-GAN/networks/nn_blocks.py in conv_block(input_tensor, f, use_norm, strides, w_l2, norm) 126 def conv_block(input_tensor, f, use_norm=False, strides=2, w_l2=w_l2, norm='none'): 127 x = input_tensor --> 128 x = Conv2D(f, kernel_size=3, strides=strides, kernel_regularizer=regularizers.l2(w_l2),
129 kernel_initializer=conv_init, use_bias=False, padding="same")(x) 130 x = Activation("relu")(x)

NameError: name 'regularizers' is not defined

shradda8 avatar Jan 08 '20 21:01 shradda8

I still didn't solve the issue, even I add the "from keras import regularizers" in file networks/nn_blocks.py

L-KH avatar Feb 21 '20 11:02 L-KH

As Shaoanlu mentioned, it can be fixed by downgrade the Keras version. Put it somewhere reasonable.

!pip install q keras==2.1.5

sharpzhao avatar May 14 '20 06:05 sharpzhao

I'm not getting the regularizers error message anymore, putting that import in nn_blocks.py fixed it. However, I am now getting this error:

---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-16-200e84530ca7> in <module>
      5 train_AnB = train_A + train_B
      6 
----> 7 assert len(train_A), "No image found in " + str(img_dirA)
      8 assert len(train_B), "No image found in " + str(img_dirB)
      9 print ("Number of images in folder A: " + str(len(train_A)))

AssertionError: No image found in ./faceA

nhorton04 avatar Aug 28 '20 05:08 nhorton04

this worked for me !pip install keras==2.1.3 !pip install h5py==2.10

jinsu35 avatar Aug 22 '21 08:08 jinsu35