shaoanlu / faceswap-GAN

A denoising autoencoder + adversarial losses and attention mechanisms for face swapping.
3.36k stars 845 forks source link

name 'regularizers' is not defined #144

Open L-KH opened 4 years ago

L-KH commented 4 years ago

//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
shaoanlu commented 4 years ago

Downgrading Keras will solve this issue.

L-KH commented 4 years ago

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

ok-sweat commented 4 years ago

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

AlasdairWalker commented 4 years ago

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

Mario2712 commented 4 years ago

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.

ok-sweat commented 4 years ago

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

Alkatraz91 commented 4 years ago

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

shradda8 commented 4 years ago

@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
L-KH commented 4 years ago

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

sharpzhao commented 4 years ago

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

!pip install q keras==2.1.5
nhorton04 commented 3 years ago

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
jinsu35 commented 2 years ago

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