eps696 / stylegan2ada Goto Github PK
View Code? Open in Web Editor NEWStyleGAN2-ada for practice
License: Other
StyleGAN2-ada for practice
License: Other
Hello, thank you very much for the great repo.
For non-square experiments I use your repo with Google Colab (not Pro), here unfortunately the connection often breaks down unexpectedly, which is why I would like to change snaps from default=5 to 1. But I always get this error:
/content/sg2-ada-pt-eps696/src Traceback (most recent call last): File "train.py", line 406, in <module> main() # pylint: disable=no-value-for-parameter File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 829, in __call__ return self.main(*args, **kwargs) File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 782, in main rv = self.invoke(ctx) File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 1066, in invoke return ctx.invoke(self.callback, **ctx.params) File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 610, in invoke return callback(*args, **kwargs) File "/usr/local/lib/python3.7/dist-packages/click/decorators.py", line 21, in new_func return f(get_current_context(), *args, **kwargs) File "train.py", line 353, in main run_desc, args = setup_training_loop_kwargs(**config_kwargs) File "train.py", line 61, in setup_training_loop_kwargs assert snap > 1, '--snap must be at least 1' AssertionError: --snap must be at least 1
I start my training with this command:
!python train.py
--train_dir=/content/googledrive/MyDrive
--data=/content/720x1280-Test.zip
--cfg="eps"
--mirror=True
--snap=1
--seed=0
--kimg=25000
--aug=ada
--target=0.699
--augpipe=bgc
--gamma=6
--workers=2
All the relative paths are confusing.
Hi!
I'm trying to fine tune a model i found here: https://thisbeachdoesnotexist.com/
Model specs:
StyleGAN2-Ada
Dataset 20.000 images
Network size 362 MB
Resolution 1280ร768 px
Network layout 5ร3 squares (with 28 = 256 px sides)
Training options --min_w=5 --min_h=3 --res_log2=8
Trained using RoyWheels/stylegan2-ada (github)
Training steps 25.000 kimg
Metric FID50k 3.14
I get this warning
Resuming from "/G/MyDrive/sg2a_eps/train/beach-network-snapshot-025000.pkl", kimg 0
warning: unknown TF kwargs ['res_log2', 'min_w', 'min_h']
and then this error
AssertionError Traceback (most recent call last)
/G/MyDrive/sg2a_eps/src/train.py in ()
407 spec = "ModuleSpec(name='builtins', loader=<class '_frozen_importlib.BuiltinImporter'>)"
408
--> 409 main() # pylint: disable=no-value-for-parameter
410
13 frames
/G/MyDrive/sg2a_eps/src/training/networks.py in init(self, w_dim, img_resolution, img_channels, init_res, channel_base, channel_max, num_fp16_res, **block_kwargs)
451 **block_kwargs, # Arguments for SynthesisBlock.
452 ):
--> 453 assert img_resolution >= 4 and img_resolution & (img_resolution - 1) == 0
454 super().init()
455 self.w_dim = w_dim
AssertionError:
My dataset is in 1280x768.
I've been able to train with my dataset from scratch, but having this problem when doing transfer learning from this beach model.
Thank You!
Hi @eps696 first of all many thanks for your code.
I'm using your colab notebook to try to change aspect ratio of a model. After trying some models without success I found in another issue a model that it was supposed to work:
Issue "Arbitrary resolution for torch models #2"
Model https://drive.google.com/file/d/1OHuKMJFH0b85ql2vMrD9bWYFjAiwvXAE/view
But also using this model I'm getting this error:
AssertionError: !! G/D subnets not found in source model !!
Is it a only colab issue? Any hint?
Many thanks
Hi!
I think it is more likely that I did something wrong, but I can't generate anything with a non-native resolution.
I made a small research and found that legacy.py is used for loading models and resolution change is applied only for models converted from tensorflow.
Anyway, repo is great, thanks for your work!
Similar to the stylegan2-ada
repo, is it possible to specify seeds when using the generate script?
ie gen.bat ffhq-1024.pkl --seeds=0-100
Your commits seem to have very brief descriptions, and I can't find the changes specific to the features you've added. I'd like to take just the changes relating to non-square aspect ratio support.
Would it be possible for you to help me isolate these changes and put them in a separate branch?
Hi,
I was using the official StyleGAN2-ada from NVIDIA's pytorch repo, which worked well but do not allow to directly train on rectangular images. So I am trying this repo (thanks for the work !) on 768x1024 images.
The saved _reals.jpg images look totally fine. But after 4368kimg the generator is still outputting "crap". See the output of fake-4368.jpg below:
Has anyone faced this please ? The only configuration I provide to the training is --batch 8 --kimg 10000 and the dataset is about 40k images all cropped to 768x1024. I have inspected the dataset, its curated and of consistent quality.
Thanks for any hints, would be nice not to spend too much runs into black and green glitches .. (the targets are natural images)
Hi!
I wanted to know if its posible to resume aug and kimg value from latest training when resuming training.
Thank you!
I'm experiencing a weird behavior with the drive folder keeping unmounting. After running the general setup cell and successfully downloading files in sg2a_eps I get
ERROR:root:File 'src/train.py'
not found.
[Errno 107] Transport endpoint is not connected: '/G/MyDrive/sg2a_eps/'
/G/MyDrive/sg2a_eps
Installing collected packages: ninja
Successfully installed ninja-1.10.0.post2
Mounted at /G
/G/MyDrive
/G/MyDrive/sg2a_eps
Requirement already satisfied: click in /usr/local/lib/python3.7/dist-packages (from -r requirements.txt (line 1)) (7.1.2)
Requirement already satisfied: psutil in /usr/local/lib/python3.7/dist-packages (from -r requirements.txt (line 2)) (5.4.8)
.. Done ..
why I am getting this error?
TypeError: 'tuple' object is not callable
when I remove --aug=ada --target=0.7 and give no aug it works
I am training on rgba images, none of aug is working, previously it was working now its failing.
%run src/train.py --data data/mydata --resume train/035-mydata-512-big-target0.7-gf_bnc --batch=20 --kimg 1000 --mirror=False --aug=ada --target=0.7 --cfg="big"
Hey Vadim,
I seem to be having this error whenever I try to generate using custom size, multi-latent generation or 'other tricks' digression mode.
Native generation seems to be working just fine, but I'm really missing these features as compared to the original SG2.
I'm trying to generate from a SG2-ada-pytorch .pkl.
Thanks for your work on maintaining this repo!
Thanks for setting this up. Trying this on rbga images, so hoping it works. Just as an fyi, unlike stylegan2-ada it looks like the kimg arg needs to be specified when training otherwise it breaks. Should it be defaulted?
Hi, thank you for the excellent repo. I have a query about the train.py file, does the train.py use the StyleGAN2-ADA network from network.py or stylegan2_multi.py file because I see 2 different Generator Classes defined in each of the files? Also, apologies if this is a trivial question.
Thank you for your repos. While the TF version runs on Colab, running the Pytorch version throws the following exception on Colab
RuntimeError: derivative for grid_sampler_2d_backward is not implemented
I want to train with fine-tune style.
But I could not find pre-trained model named ffhq-256.pkl in /train/.
Is there any link or urls to download them?
I get an assertion error when I try to use multi-latent generation in both Google Colab and running locally in Jupyter notebook on Ubuntu in a working sg2ada environment.
Native generation works fine in both cases.
Would love to try multi-latents but not sure what to do with this one! Thanks for any help!
*Edit - In case it's relevant, this is an SG2-ADA model that was trained originally in Tensorflow and then converted to pytorch using Derrick's legacy.py
**Edit again - Fixed now! I had been using a TF model. Still had an error using one converted with legacy.py, but then tried your model_convert.py and all is working now!
Colab error message looks like this:
/G/MyDrive/sg2a_eps
.. Gs custom .. network-snapshot-000230
latents (20, 3, 512)
0/20
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
[/G/MyDrive/sg2a_eps/src/_genSGAN2.py](https://localhost:8080/#) in <module>
164
165 if __name__ == '__main__':
--> 166 generate()
6 frames
[/G/MyDrive/sg2a_eps/src/_genSGAN2.py](https://localhost:8080/#) in generate()
140 # generate multi-latent result
141 if custom:
--> 142 output = Gs(latent, label, latmask, dc, truncation_psi=a.trunc, noise_mode='const')
143 else:
144 output = Gs(latent, label, truncation_psi=a.trunc, noise_mode='const')
[/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py](https://localhost:8080/#) in _call_impl(self, *input, **kwargs)
725 result = self._slow_forward(*input, **kwargs)
726 else:
--> 727 result = self.forward(*input, **kwargs)
728 for hook in itertools.chain(
729 _global_forward_hooks.values(),
[/G/MyDrive/sg2a_eps/src/training/stylegan2_multi.py](https://localhost:8080/#) in forward(self, z, c, latmask, dconst, truncation_psi, truncation_cutoff, **synthesis_kwargs)
403 # def forward(self, z, c, truncation_psi=1, truncation_cutoff=None, **synthesis_kwargs):
404 ws = self.mapping(z, c, truncation_psi=truncation_psi, truncation_cutoff=truncation_cutoff)
--> 405 img = self.synthesis(ws, latmask, dconst, **synthesis_kwargs) # !!! custom
406 return img
407
[/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py](https://localhost:8080/#) in _call_impl(self, *input, **kwargs)
725 result = self._slow_forward(*input, **kwargs)
726 else:
--> 727 result = self.forward(*input, **kwargs)
728 for hook in itertools.chain(
729 _global_forward_hooks.values(),
[/G/MyDrive/sg2a_eps/src/training/stylegan2_multi.py](https://localhost:8080/#) in forward(self, ws, latmask, dconst, **block_kwargs)
366 block = getattr(self, f'b{res}')
367 # !!! custom
--> 368 x, img = block(x, img, cur_ws, latmask, dconst, **block_kwargs)
369 # x, img = block(x, img, cur_ws, **block_kwargs)
370 return img
[/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py](https://localhost:8080/#) in _call_impl(self, *input, **kwargs)
725 result = self._slow_forward(*input, **kwargs)
726 else:
--> 727 result = self.forward(*input, **kwargs)
728 for hook in itertools.chain(
729 _global_forward_hooks.values(),
[/G/MyDrive/sg2a_eps/src/training/stylegan2_multi.py](https://localhost:8080/#) in forward(self, x, img, ws, latmask, dconst, force_fp32, fused_modconv, **layer_kwargs)
295 img = img.add_(y) if img is not None else y
296
--> 297 assert x.dtype == dtype
298 assert img is None or img.dtype == torch.float32
299 return x, img
AssertionError:
The local Jupyter traceback is almost the same but references some different lines.
Hi there, Im trying to change a 512x1024 model into a 1024x1024 model, it says success and outputs a model but its size is still 512x1024 or atleast when I try to infer at 1024x1024 it gives me the error:
size mismatch for noises.noise_16: copying a param with shape torch.Size([1, 1, 1024, 512]) from checkpoint, the shape in current model is torch.Size([1, 1, 1024, 1024]).
Thanks!
Can it be used to train RGBA images?
I am trying to train with rgba images, but its going to gradient explosion, I tried to reduce the learning rate but nothing seems to work.
Can somebody help? My dataset has about 2k unique images and I pumped it upto 60k images with augmentation.
Finetuning by adding alpha to other rgb models did not go well, Im training from scratch.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.