Giter VIP home page Giter VIP logo

eladrich / pixel2style2pixel Goto Github PK

View Code? Open in Web Editor NEW
3.2K 64.0 570.0 92.94 MB

Official Implementation for "Encoding in Style: a StyleGAN Encoder for Image-to-Image Translation" (CVPR 2021) presenting the pixel2style2pixel (pSp) framework

Home Page: https://eladrich.github.io/pixel2style2pixel/

License: MIT License

Python 3.91% C++ 0.04% Cuda 0.26% Jupyter Notebook 95.75% Shell 0.04%
image-translation stylegan generative-adversarial-network stylegan-encoder cvpr2021 pixel2style2pixel psp-model psp-framework

pixel2style2pixel's People

Contributors

amrzv avatar chenxwh avatar eladrich avatar yuval-alaluf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pixel2style2pixel's Issues

Minimum GPU requirements for 1024

Thanks for your great work !!!

I want to train the StyleGAN encoding model with FFHQ 1024x1024 dataset, what is the minimum gpu requirements for the training?

Thank you.

The network output is slightly different from our expectations

Hi,
we use about 50k pairs of pictures generated by Toonify Stylegan to do pairs-training, and use the Toonify model provided in the readme as the weight.
After training, the results in the log are all very good. However, other results are not as expected.

For example, this image is given by the latent code optimized by Stylegan.

However, pixel2style2pixel gives this one.
773edbb674b99d79

More training results from pixel2style2pixel:
-5bfb05277a409917
-730846ae16b2e1f9

What's the functionality of applying EqualLinear in psp_encoders

For psp_encoders.py L148
x = x.view(-1, 512) It's supposed to get the latent from here but it seems you do an EqualLinear further in the next step:
x = self.linear(x)
What's the function here? I see all these Encoders have applied for EqualLinear.
Any experimental differences if get rid of this layer? I didn't find them in the paper so post here.
Looking forward to hearing your clarifying! Appreciate it!

Colab Error

Hi!
Thanks for your wonderful work.

But, I founded that an error occurs when i execute your colab example, even i did not touch any code.
Error :
image

can you please check it?

Pausing for testing during training

Hi

I am in the process of retraining the encoder and was wondering what the procedure would be for testing the checkpoints as expectedly there isn't enough memory to train and test at the same time.

It's been training for roughly 2/3 days now. Would I pause training and test, or terminate training and test and then if desired restart training from the best checkpoint?

Are there flags for pausing etc?

Cheers!

Question for toonification model

Hi, thanks again for the great work.

"We train the pSp encoder to directly reconstruct real face images inside the toons latent space resulting in a projection of each image to the closest toon."

Regarding the above statement, did you mean that your pSp encoder was trained with a dataset consisting of only FFHQ images, not Toonified images? If so, were reconstructed images (Toonified by generator) and input images (FFHQ ) were used for calculating losses?

Does this support 1024*1024?

Hi, thanks again for the great work.
I'm trying to train a Toonify model on it. But I just notice that the default resolution is 256256 according to the provided transforms_config.py. Can I train this model under 10241024 resolution by simply changing the transforms_config.py settings?

Downloading models

I have permission issue downloading pre-trained models from provided google drive links

UnpicklingError: invalid load key, '<'.

Hi?

I encountered this error message
UnpicklingError: invalid load key, '<'.

after I run this cell
model_path = EXPERIMENT_ARGS['model_path']
ckpt = torch.load(model_path, map_location='cpu')

Can someone help me?

I'm trying this in colab notebook.

enviroment error?

Hi~ thanks for your amazing work. I try to follow your work but I am currently experiencing some problems.
Based on experience, I guess it should be an environmental problem.
My enviroment:

pytorch - 1.3.1

torchvision - 0.4.2

cuda - 10.1.0

cudnn - 7.6.3
Hope to get your help. Many Thanks!

Traceback (most recent call last):
File "/home/dongshichao/.local/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 1030, in _build_extension_module
check=True)
File "/usr/lib/python3.6/subprocess.py", line 438, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/pudb/init.py", line 153, in runscript
dbg.runscript(mainpyfile)
File "/usr/local/lib/python3.6/dist-packages/pudb/debugger.py", line 468, in runscript
self.run(statement)
File "/usr/lib/python3.6/bdb.py", line 434, in run
exec(cmd, globals, locals)
File "", line 1, in
File "dsc_demo.py", line 18, in
from models.psp import pSp
File "../models/psp.py", line 9, in
from models.encoders import psp_encoders
File "../models/encoders/psp_encoders.py", line 8, in
from models.stylegan2.model import EqualLinear
File "../models/stylegan2/model.py", line 7, in
from models.stylegan2.op import FusedLeakyReLU, fused_leaky_relu, upfirdn2d
File "../models/stylegan2/op/init.py", line 1, in
from .fused_act import FusedLeakyReLU, fused_leaky_relu
File "../models/stylegan2/op/fused_act.py", line 13, in
os.path.join(module_path, 'fused_bias_act_kernel.cu'),
File "/home/dongshichao/.local/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 661, in load
is_python_module)
File "/home/dongshichao/.local/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 830, in jit_compile
with_cuda=with_cuda)
File "/home/dongshichao/.local/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 883, in write_ninja_file_and_build
build_extension_module(name, build_directory, verbose)
File "/home/dongshichao/.local/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 1043, in build_extension_module
raise RuntimeError(message)
RuntimeError: Error building extension 'fused': [1/3] :/data/cuda/cuda-10.1/cuda/:/data/cuda/cuda-10.1/cuda/bin/nvcc -DTORCH_EXTENSION_NAME=fused -DTORCH_API_INCLUDE_EXTENSION_H -isystem /home/dongshichao/.local/lib/python3.6/site-packages/torch/include -isystem /home/dongshichao/.local/lib/python3.6/site-packages/torch/include/torch/csrc/api/include -isystem /home/dongshichao/.local/lib/python3.6/site-packages/torch/include/TH -isystem /home/dongshichao/.local/lib/python3.6/site-packages/torch/include/THC -isystem :/data/cuda/cuda-10.1/cuda/:/data/cuda/cuda-10.1/cuda/include -isystem /usr/include/python3.6m -D_GLIBCXX_USE_CXX11_ABI=0 -D__CUDA_NO_HALF_OPERATORS -D__CUDA_NO_HALF_CONVERSIONS -D__CUDA_NO_HALF2_OPERATORS --expt-relaxed-constexpr -gencode=arch=compute_75,code=sm_75 --compiler-options '-fPIC' -std=c++11 -c /data/jupyter/pixel2style2pixel/models/stylegan2/op/fused_bias_act_kernel.cu -o fused_bias_act_kernel.cuda.o
FAILED: fused_bias_act_kernel.cuda.o
:/data/cuda/cuda-10.1/cuda/:/data/cuda/cuda-10.1/cuda/bin/nvcc -DTORCH_EXTENSION_NAME=fused -DTORCH_API_INCLUDE_EXTENSION_H -isystem /home/dongshichao/.local/lib/python3.6/site-packages/torch/include -isystem /home/dongshichao/.local/lib/python3.6/site-packages/torch/include/torch/csrc/api/include -isystem /home/dongshichao/.local/lib/python3.6/site-packages/torch/include/TH -isystem /home/dongshichao/.local/lib/python3.6/site-packages/torch/include/THC -isystem :/data/cuda/cuda-10.1/cuda/:/data/cuda/cuda-10.1/cuda/include -isystem /usr/include/python3.6m -D_GLIBCXX_USE_CXX11_ABI=0 -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr -gencode=arch=compute_75,code=sm_75 --compiler-options '-fPIC' -std=c++11 -c /data/jupyter/pixel2style2pixel/models/stylegan2/op/fused_bias_act_kernel.cu -o fused_bias_act_kernel.cuda.o
/bin/sh: 1: :/data/cuda/cuda-10.1/cuda/:/data/cuda/cuda-10.1/cuda/bin/nvcc: not found
[2/3] c++ -MMD -MF fused_bias_act.o.d -DTORCH_EXTENSION_NAME=fused -DTORCH_API_INCLUDE_EXTENSION_H -isystem /home/dongshichao/.local/lib/python3.6/site-packages/torch/include -isystem /home/dongshichao/.local/lib/python3.6/site-packages/torch/include/torch/csrc/api/include -isystem /home/dongshichao/.local/lib/python3.6/site-packages/torch/include/TH -isystem /home/dongshichao/.local/lib/python3.6/site-packages/torch/include/THC -isystem :/data/cuda/cuda-10.1/cuda/:/data/cuda/cuda-10.1/cuda/include -isystem /usr/include/python3.6m -D_GLIBCXX_USE_CXX11_ABI=0 -fPIC -std=c++11 -c /data/jupyter/pixel2style2pixel/models/stylegan2/op/fused_bias_act.cpp -o fused_bias_act.o
ninja: build stopped: subcommand failed.

why our model generate a image suround by a block shadow

The Source Domain data of stylegan2, the pre-training model we adopted, is FFHQ dataset, while the target Domain dataset is some cartoon images. Stylegan2, on the other hand, produces good cartoon images. When we use this Stylegan2 to train the PSP model, both the Source Domain and target Domain datasets of the PSP model are FFHQ data. Something weird happens, and all the generated images are surrounded by a shadow of a square. We don't know if you have encountered this problem or if you have any solutions?

Toonify model seems not work

I used notebook of Inference_playground.ipynb and try various experiment type with default settings. All other experiment type work well except type of "toonify":
it seems that no matter which kinds of image i used, the results are all similar like this:
result

Running inference on a CPU

Thank you for sharing this code.

In the README you say it might be possible to run this on a CPU. I am specifically interesting in running the inference on a CPU. Can you point out what that needs to be changed in order to adapt inference to run on a CPU?

Also a side question on parameters tuning for training.
What parameters should I tune in order to improve the ability for the model to include more details like facial marks (freckles, moles, wrinkles). It seams my model trained below parameters is omitting these details.
--lpips_lambda=0.8
--l2_lambda=1
--id_lambda=0
--w_norm_lambda=0.005
--lpips_lambda_crop=0.8

Thanks again!

Encoding my own images

Hello, newbie here.
I opened your project in Colab but couldn't manage to encode my own images. I tried manually uploading my images to the "inversion_images" folder, but got some undesirable results. I believe the reason is that the images need to be aligned and resized before being fed to pSp. So, how can I achieve this?

how to test toonify

Thank you for your great work and share the codes.
Can you supply a brief explanation about how to test the Toonify?

dependency install issue

Hello. I just use the following command in Window 10 64bit home edition
conda env create -f C:\Users\User\Downloads\pixel2style2pixel\environment\psp_env.yaml

And I get the following error
**ResolvePackageNotFound:

  • ncurses==6.2=he6710b0_1
  • python==3.6.7=h0371630_0
  • libstdcxx-ng==9.1.0=hdf63c60_0
  • readline==7.0=h7b6447c_5
  • sqlite==3.31.1=h62c20be_1
  • zlib==1.2.11=h7b6447c_3
  • libedit==3.1.20181209=hc058e9b_0
  • xz==5.2.5=h7b6447c_0
  • libffi==3.2.1=hd88cf55_4
  • ninja==1.10.0=hc9558a2_0
  • tk==8.6.8=hbc83047_0
  • libgcc-ng==9.1.0=hdf63c60_0
  • openssl==1.1.1g=h516909a_0**

How would I solve this issue? Thank you for any reply.

stylegan2 pytorch weights

that's so excellent result for image encoding. And i want to kown how convert stylegan2 weights from official tensorflow implement to pytorch? thanks!

No instructions on how to train an inpainting model

pSp Encoder, Frontalization, Sketch to Face, Segmentation Map to Face and Super Resolution do have instructions, but there are none for inpainting. Would it be possible to add instructions to the readme? And I assume there is no mask related code, since I can't find code related to that. How are masks supposed to be used or needs this to be implemented?

Inference.py error

Hello again

I've moved from working in the jupyter notebook to working via terminal in the conda environment. I have been using style_mixing.py with no problems and with good results. However, when trying to run inference.py (which worked fine in the jupyter notebook) I am getting the following error:

inference-error

Apologies for asking again!

Conda environment error

Hello

I am receiving an error when running this via jupyter notebook. I have installed the specified torch/torchvision versions from the .yaml (along with everything else) to my conda environment and even uninstalled/reinstalled to check. Is this error something to do with the conflicting and 'incompatible' versions listed in the .yaml or have I missed out something when installing them into the conda environment? I am new to both linux and gan/ml work.

Cheers!

Screenshot from 2020-11-02 10-53-44

Question about ffhq_encode

I tried to train a toon model with source/target images as below
Source
source
Target
target
Result
out
Trained it till like 6000 iters as mentioned in the thread with the same settings above is just example trained the data with like 1000 images.
It does not really give the expected output it actually changes the structure of the whole face. can you give some rough idea of what I could be doing wrong? and how do I preserve the input face and somehow make the eyes a bit large?

using a different stylegan weights

Hi, thanks for the awesome work.

I'd like to train an encoder using a pre-trained 256x256 stylegan model (https://github.com/rosinality/stylegan2-pytorch) but I'm not sure using this model would be okay for your training code. Since in my case the resolution only goes up to 256, there should be 14x512 latent vectors which are less than your latent vector size, 18x512. My question is, can I still use 256x256 stylegan pre-trained model for this work?

Thanks in advance.

ninja: build stopped: subcommand failed.

Thanks for your great work! I have some problems during training the psp.
I got the error
RuntimeError: Error building extension 'fused': [1/2] :/usr/local/cuda-9.0:/usr/local/cuda-10.0/bin/nvcc -DTORCH_EXTENSION_NAME=fused -D
TORCH_API_INCLUDE_EXTENSION_H -isystem /hd1/lvyueming/anaconda3/envs/psp_env/lib/python3.6/site-packages/torch/include -isystem /hd1/lvy
ueming/anaconda3/envs/psp_env/lib/python3.6/site-packages/torch/include/torch/csrc/api/include -isystem /hd1/lvyueming/anaconda3/envs/ps
p_env/lib/python3.6/site-packages/torch/include/TH -isystem /hd1/lvyueming/anaconda3/envs/psp_env/lib/python3.6/site-packages/torch/incl
ude/THC -isystem :/usr/local/cuda-9.0:/usr/local/cuda-10.0/include -isystem /hd1/lvyueming/anaconda3/envs/psp_env/include/python3.6m -D_
GLIBCXX_USE_CXX11_ABI=0 -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constex
pr -gencode=arch=compute_75,code=sm_75 --compiler-options '-fPIC' -std=c++11 -c /home/lvyueming/pixel2style2pixel/models/stylegan2/op/fu
sed_bias_act_kernel.cu -o fused_bias_act_kernel.cuda.o
FAILED: fused_bias_act_kernel.cuda.o
:/usr/local/cuda-9.0:/usr/local/cuda-10.0/bin/nvcc -DTORCH_EXTENSION_NAME=fused -DTORCH_API_INCLUDE_EXTENSION_H -isystem /hd1/lvyueming/
anaconda3/envs/psp_env/lib/python3.6/site-packages/torch/include -isystem /hd1/lvyueming/anaconda3/envs/psp_env/lib/python3.6/site-packa
ges/torch/include/torch/csrc/api/include -isystem /hd1/lvyueming/anaconda3/envs/psp_env/lib/python3.6/site-packages/torch/include/TH -is
ystem /hd1/lvyueming/anaconda3/envs/psp_env/lib/python3.6/site-packages/torch/include/THC -isystem :/usr/local/cuda-9.0:/usr/local/cuda-
10.0/include -isystem /hd1/lvyueming/anaconda3/envs/psp_env/include/python3.6m -D_GLIBCXX_USE_CXX11_ABI=0 -D__CUDA_NO_HALF_OPERATORS__ -
D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr -gencode=arch=compute_75,code=sm_75 --compiler-opti
ons '-fPIC' -std=c++11 -c /home/lvyueming/pixel2style2pixel/models/stylegan2/op/fused_bias_act_kernel.cu -o fused_bias_act_kernel.cuda.o
/bin/sh: :/usr/local/cuda-9.0:/usr/local/cuda-10.0/bin/nvcc: No such file or directory
ninja: build stopped: subcommand failed.

could you help me fix it ?Thank you very much!

File not compiling

I have run model before it was compiling and working fine but after that immediately next day it stopped working model is not compiling I have to again again interrupt compiling and sometimes even GPU gets lost. But model does not compile or file does not compile and solution to this.

Permission Denied

Hello, when I run your project on the sever, it found that there is a permission error as follow:
(py3.6) beryl@delta:~/github/pixel2style2pixel$ python scripts/train.py --dataset_type=ffhq_encode --exp_dir=./experiment --workers=8 --batch_size=8 --test_batch_size=8 --test_workers=8 --val_interval=2500 --save_interval=5000 --encoder_type=GradualStyleEncoder --start_from_latent_avg --lpips_lambda=0.8 --l2_lambda=1 --id_lambda=0.1 Traceback (most recent call last): File "scripts/train.py", line 14, in <module> from training.coach import Coach File "./training/coach.py", line 19, in <module> from models.psp import pSp File "./models/psp.py", line 9, in <module> from models.encoders import psp_encoders File "./models/encoders/psp_encoders.py", line 8, in <module> from models.stylegan2.model import EqualLinear File "./models/stylegan2/model.py", line 7, in <module> from models.stylegan2.op import FusedLeakyReLU, fused_leaky_relu, upfirdn2d File "./models/stylegan2/op/__init__.py", line 1, in <module> from .fused_act import FusedLeakyReLU, fused_leaky_relu File "./models/stylegan2/op/fused_act.py", line 13, in <module> os.path.join(module_path, 'fused_bias_act_kernel.cu'), File "/mnt/lab/beryl/anaconda3/envs/py3.6/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 898, in load is_python_module) File "/mnt/lab/beryl/anaconda3/envs/py3.6/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 1075, in _jit_compile if baton.try_acquire(): File "/mnt/lab/beryl/anaconda3/envs/py3.6/lib/python3.6/site-packages/torch/utils/file_baton.py", line 36, in try_acquire self.fd = os.open(self.lock_file_path, os.O_CREAT | os.O_EXCL) PermissionError: [Errno 13] Permission denied: '/tmp/torch_extensions/fused/lock'

But when I use the sudo demand, another error accurs:
(py3.6) beryl@delta:~/github/pixel2style2pixel$ sudo python scripts/train.py --dataset_type=ffhq_encode --exp_dir=./experiment --workers=8 --batch_size=8 --test_batch_size=8 --test_workers=8 --val_interval=2500 --save_interval=5000 --encoder_type=GradualStyleEncoder --start_from_latent_avg --lpips_lambda=0.8 --l2_lambda=1 --id_lambda=0.1 Traceback (most recent call last): File "scripts/train.py", line 14, in <module> from training.coach import Coach File "./training/coach.py", line 3, in <module> import matplotlib ImportError: No module named matplotlib
This error seems that the file is not run on the proper environment, because I am using the anaconda environment while the environment has matplotlib package. Can you provide me some help? Thanks!

How to get W+ space for the encoded images ?

I tried running inference on a set of images for encoding in the FFHQ latent space, it gave me a set of projected images. But no .npy file associated with it for W+ space as cited in the paper to do further image maniputations.

Is it possible to get the W+ space vectors ?

hi ,how do what and get good result in ffhq_encode

hi
can u give some idea , how to use
batch_size': '8',
'board_interval': 50,
'checkpoint_path': None,
'dataset_type': 'ffhq_encode',
'device': 'cuda:0',
'encoder_type': 'GradualStyleEncoder',
'exp_dir': '',
'id_lambda': 0.1,
'image_interval': 100,
'input_nc': 3,
'l2_lambda': 1.0,
'l2_lambda_crop': 0,
'label_nc': 0,
'learn_in_w': False,
'learning_rate': 0.0001,
'lpips_lambda': 0.8,
'lpips_lambda_crop': 0,
'max_steps': 300000,
'optim_name': 'ranger',
'resize_factors': None,
'save_interval': '10000',
'start_from_latent_avg': True,
'stylegan_weights': '',
'test_batch_size': '6',
'test_workers': 2,
'train_decoder': False,
'val_interval': 2500,
'w_norm_lambda': 0,
'workers': '8'}

About alignment

Thanks for your excellent work! I have read your code, and I find you don't use any alignment in training encoder for id_loss, so if I want to training on my own datasets, alignment should be done before training, right?

Licensing

I know it's licensed under MIT.

However, would you consider adding a license file (which can be parsed automatically) and a copyright notice? The MIT license is confusing without a copyright notice.

In addition, users of this might not immediately be aware of the restrictions of those files under the Nvidia Source Code License-NC: using this repo as if it was wholly MIT-licensed isn't safe.

It'd be nice to put a mention about these files in the readme.

I think there are other files with third-party rights associated with them.

In general, the licensing status of this project is quite unclear. Would you consider clarifying it a bit?

How to use generator to generate random image?

Great job! @eladrich.
I was wondering how to use you Generator implementation to generate some random images.
I found the forward code in models/stylegan2/model.py and it looks like:

    def forward(
            self,
            styles,
            return_latents=False,
            return_features=False,
            inject_index=None,
            truncation=1,
            truncation_latent=None,
            input_is_latent=False,
            noise=None,
            randomize_noise=True,
    ):
        if not input_is_latent:
            styles = [self.style(s) for s in styles]

        if noise is None:
            if randomize_noise:
                noise = [None] * self.num_layers
            else:
                noise = [
                    getattr(self.noises, f'noise_{i}') for i in range(self.num_layers)
                ]

I am a little about the argument styles for? can I generate a noise via make_noise() and then generate a random face image?

Best regard!

Latents Portability

I was interested to pick your brain regarding the portability of the generated latent representation, especially across models and frameworks.

I did extensive experiments with StyleGAN, mostly in its Tensorflow version, and have seen code like the rosinality one, meant to convert model checkpoints.

To train a new psp model I need to specify a previously trained Pytorch StyleGAN2 model, and then I can simply obtain projected/encoded latents from the psp model and use them in my original Pytorch one. However these latents don't seem to be portable to a Tensorflow model, say one I converted to Pytorch with a utility as mentioned above.

Did you do any experiments regarding this? Would you suggest me to simply move my latents-editing setup to Pytorch or do you have any ideas?

how to get each picture's latent code?

I set the 'return_latents=True' in psp.py , but get TypeError :


Traceback (most recent call last):
File "/home/zhz1/anaconda3/envs/env_36/lib/python3.7/site-packages/PIL/Image.py", line 2751, in fromarray
mode, rawmode = _fromarray_typemap[typekey]
KeyError: ((1, 1, 1, 256), '|u1')

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "scripts/inference.py", line 136, in
run()
File "scripts/inference.py", line 82, in run
result = tensor2im(result_batch[i])
File "./utils/common.py", line 23, in tensor2im
return Image.fromarray(var.astype('uint8'))
File "/home/zhz1/anaconda3/envs/env_36/lib/python3.7/site-packages/PIL/Image.py", line 2753, in fromarray
raise TypeError("Cannot handle this data type: %s, %s" % typekey) from e
TypeError: Cannot handle this data type: (1, 1, 1, 256), |u1

could you please tell me how to output each picture's latent code?

CelebAMask-HQ

Hello authors, thanks for this amazing repo!

I know it's not really your problem, but the CelebAMask-HQ Dataset is not currently available from the original authors (their Google Drive download link is broken).

Since you have a copy of the dataset, and the dataset isn't very big (I think it's < 3GB), would you be able to put it on Google Drive or some other platform?

how to perform loss for Generating face from sketches

I assume the input is the sketch image (A) but the generated image (B) is a normal face. Is the LPIPS loss performed between A and B? It seems doesn't make sense for me. Could you please clarify more here regarding the loss perform?

RuntimeError: psp_ffhq_toonify.pt is a zip archive (did you mean to use torch.jit.load()?)

environments:
python 3.6.7
torch 1.3.1
torchvision 0.4.2
CUDA 10.1

Traceback (most recent call last):
File "/root/anaconda3/envs/psp_env/lib/python3.6/tarfile.py", line 189, in nti
n = int(s.strip() or "0", 8)
ValueError: invalid literal for int() with base 8: 'ightq\x04ct'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/root/anaconda3/envs/psp_env/lib/python3.6/tarfile.py", line 2297, in next
tarinfo = self.tarinfo.fromtarfile(self)
File "/root/anaconda3/envs/psp_env/lib/python3.6/tarfile.py", line 1093, in fromtarfile
obj = cls.frombuf(buf, tarfile.encoding, tarfile.errors)
File "/root/anaconda3/envs/psp_env/lib/python3.6/tarfile.py", line 1035, in frombuf
chksum = nti(buf[148:156])
File "/root/anaconda3/envs/psp_env/lib/python3.6/tarfile.py", line 191, in nti
raise InvalidHeaderError("invalid header")
tarfile.InvalidHeaderError: invalid header

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/root/anaconda3/envs/psp_env/lib/python3.6/site-packages/torch/serialization.py", line 595, in _load
return legacy_load(f)
File "/root/anaconda3/envs/psp_env/lib/python3.6/site-packages/torch/serialization.py", line 506, in legacy_load
with closing(tarfile.open(fileobj=f, mode='r:', format=tarfile.PAX_FORMAT)) as tar,
File "/root/anaconda3/envs/psp_env/lib/python3.6/tarfile.py", line 1589, in open
return func(name, filemode, fileobj, **kwargs)
File "/root/anaconda3/envs/psp_env/lib/python3.6/tarfile.py", line 1619, in taropen
return cls(name, mode, fileobj, **kwargs)
File "/root/anaconda3/envs/psp_env/lib/python3.6/tarfile.py", line 1482, in init
self.firstmember = self.next()
File "/root/anaconda3/envs/psp_env/lib/python3.6/tarfile.py", line 2309, in next
raise ReadError(str(e))
tarfile.ReadError: invalid header

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "scripts/inference.py", line 131, in
run()
File "scripts/inference.py", line 43, in run
ckpt = torch.load(test_opts.checkpoint_path, map_location='cpu')
File "/root/anaconda3/envs/psp_env/lib/python3.6/site-packages/torch/serialization.py", line 426, in load
return _load(f, map_location, pickle_module, **pickle_load_args)
File "/root/anaconda3/envs/psp_env/lib/python3.6/site-packages/torch/serialization.py", line 599, in _load
raise RuntimeError("{} is a zip archive (did you mean to use torch.jit.load()?)".format(f.name))
RuntimeError: psp_ffhq_toonify.pt is a zip archive (did you mean to use torch.jit.load()?)

Using inference for own images problem

Hi @eladrich. Thanks for sharing.
I would like to try inference with own srcs , but maybe i am to stupid or it is not made for.
Am i right,that for input there is an folder which parameter is:
--data_path
this points to folder where my input images are (more than one?)

output folder is:
-exp_dir

i tried with input_img.jpg in folder:
python inference.py --checkpoint_path ../pretrained_models/psp_celebs_super_resolution.pt --exp_dir ../../out --data_path ../../in/ --resize_factors 2 --test_batch_size 2

Loading pSp from checkpoint: ../pretrained_models/psp_celebs_super_resolution.pt
Loading dataset for celebs_super_resolution
Performing down-sampling with factors: [2]
0it [00:00, ?it/s]
/.../anaconda3/envs/pixel2style2pixel/lib/python3.6/site-packages/numpy/core/fromnumeric.py:3335: RuntimeWarning: Mean of empty slice.
out=out, **kwargs)
/.../anaconda3/envs/pixel2style2pixel/lib/python3.6/site-packages/numpy/core/_methods.py:161: RuntimeWarning: invalid value encountered in double_scalars
ret = ret.dtype.type(ret / rcount)
/.../anaconda3/envs/pixel2style2pixel/lib/python3.6/site-packages/numpy/core/_methods.py:217: RuntimeWarning: Degrees of freedom <= 0 for slice
keepdims=keepdims)
/.../anaconda3/envs/pixel2style2pixel/lib/python3.6/site-packages/numpy/core/_methods.py:186: RuntimeWarning: invalid value encountered in true_divide
arrmean, rcount, out=arrmean, casting='unsafe', subok=False)
/.../anaconda3/envs/pixel2style2pixel/lib/python3.6/site-packages/numpy/core/_methods.py:209: RuntimeWarning: invalid value encountered in double_scalars
ret = ret.dtype.type(ret / rcount)
Runtime nan+-nan

Thanks

Colab Sketch To Face not working as expected

I've been playing with the Google Colab notebook and everything seems to be working fine with the celebs_sketch_to_face model, but if I change the sketch image path to my own source image, the output is always the same default image and doesn't seem to bear any resemblance to the source sketch. Is this maybe a file naming issue? I've tried various combinations of file names, and JPG or PNG formats, and nothing seems to resolve it.

class EncodeTransforms in transfroms_config.py

In configs/transforms_config.py line 16, I was wondering why no transformation is applied in the transform_source part. Is this part deleted by some chance?

def get_transforms(self):
transforms_dict = {
'transform_gt_train': transforms.Compose([
transforms.Resize((256, 256)),
transforms.RandomHorizontalFlip(0.5),
transforms.ToTensor(),
transforms.Normalize([0.5, 0.5, 0.5], [0.5, 0.5, 0.5])]),
'transform_source': None,
'transform_test': transforms.Compose([
transforms.Resize((256, 256)),
transforms.ToTensor(),
transforms.Normalize([0.5, 0.5, 0.5], [0.5, 0.5, 0.5])]),
'transform_inference': transforms.Compose([
transforms.Resize((256, 256)),
transforms.ToTensor(),
transforms.Normalize([0.5, 0.5, 0.5], [0.5, 0.5, 0.5])])
}
return transforms_dict

WNormLoss

Thanks for your open code. I want to konw how the WNormLoss work in the training, and if I don't use it, it will or not influence the results?

How can we just transfer image style rather than get similar image?

Hello, we use your toonify parameter setting train a psp model and we get good results, but all these transfered images are just similar with the original images, like this:
original image:
00004
transfered image by using psp:
00004
but actually we want to get image like this:
00004 (1)
So, how can we just transfer image style rather than get similar but different image?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.