mikael-alafriz-deel / lucid-sonic-dreams

MIT License
773 stars 158 forks source link

Only the abstract photo style is working #9

Open uhapppy opened 3 years ago

uhapppy commented 3 years ago

i was only able to use the asbtract photo style every other style give me this error

Downloading my little pony weights (This may take a while)... Download complete Traceback (most recent call last): File "c:/Users/JF/Desktop/music/music.py", line 10, in <module> L.hallucinate(file_name = 'hills_pony.mp4') File "C:\Users\JF\AppData\Local\Programs\Python\Python37\lib\site-packages\lucidsonicdreams\main.py", line 636, in hallucinate self.stylegan_init() File "C:\Users\JF\AppData\Local\Programs\Python\Python37\lib\site-packages\lucidsonicdreams\main.py", line 126, in stylegan_init self.Gs = pickle.load(f)[2] File "C:\Users\JF\AppData\Local\Programs\Python\Python37\lib\site-packages\dnnlib\tflib\network.py", line 279, in __setstate__ assert state["version"] in [2, 3] AssertionError

masterofshapes commented 3 years ago

Having same issue

masterofshapes commented 3 years ago

Even manually downloading the weights gave me a compile error

89Q12 commented 3 years ago

Same, I'm debugging it right now but I can't seem to find the root of the error

Wesleyliao commented 3 years ago

Similar error I'm getting with anime faces:

Preparing style...
Downloading anime faces weights (This may take a while)...
Download complete
---------------------------------------------------------------------------
UnpicklingError                           Traceback (most recent call last)
<ipython-input-4-447c2cb44ba3> in <module>()
      9               resolution = 360,
     10               start = 30,
---> 11               duration = 45)
     12 
     13 files.download("chemical_love.mp4")

1 frames
/usr/local/lib/python3.7/dist-packages/lucidsonicdreams/main.py in hallucinate(self, file_name, output_audio, fps, resolution, start, duration, save_frames, batch_size, speed_fpm, pulse_percussive, pulse_harmonic, pulse_react, motion_percussive, motion_harmonic, motion_react, motion_randomness, truncation, classes, dominant_classes_first, class_pitch_react, class_smooth_seconds, class_complexity, class_shuffle_seconds, class_shuffle_strength, contrast_strength, contrast_percussive, flash_strength, flash_percussive, custom_effects)
    634 
    635       if not callable(self.style):
--> 636         self.stylegan_init()
    637 
    638       self.style_exists = True

/usr/local/lib/python3.7/dist-packages/lucidsonicdreams/main.py in stylegan_init(self)
    124     # Load weights
    125     with open(weights_file, 'rb') as f:
--> 126       self.Gs = pickle.load(f)[2]
    127 
    128     # Auto assign num_possible_classes attribute

UnpicklingError: invalid load key, '\xfd'.
richouzo commented 3 years ago

i was only able to use the asbtract photo style every other style give me this error

Downloading my little pony weights (This may take a while)... Download complete Traceback (most recent call last): File "c:/Users/JF/Desktop/music/music.py", line 10, in <module> L.hallucinate(file_name = 'hills_pony.mp4') File "C:\Users\JF\AppData\Local\Programs\Python\Python37\lib\site-packages\lucidsonicdreams\main.py", line 636, in hallucinate self.stylegan_init() File "C:\Users\JF\AppData\Local\Programs\Python\Python37\lib\site-packages\lucidsonicdreams\main.py", line 126, in stylegan_init self.Gs = pickle.load(f)[2] File "C:\Users\JF\AppData\Local\Programs\Python\Python37\lib\site-packages\dnnlib\tflib\network.py", line 279, in __setstate__ assert state["version"] in [2, 3] AssertionError

I think your issue comes from here: https://github.com/mikaelalafriz/lucid-sonic-dreams/issues/3#issuecomment-799151100

Lucid Sonic Dreams uses the stylegan2 repo which is downloaded from this repo's main.py, and the dnnlib folder is different from the one you used in your comment above, thus making the error.  

Concerning the use of other styles, I think the main issue comes from the OS. Stylegan2 is currently supported for tensorflow 1.15 on Linux, but not on Windows: https://github.com/NVlabs/stylegan2#requirements Lucid Sonic Dreams uses tensorflow 1.15.

The wikiart style works well on Linux for me. But on Windows, I've got an error with Setting up TensorFlow plugin "fused_bias_act.cu" and it seems to be related to the C++ headers mentioned in my previous link.

I hope it helps.

dogadikbayir commented 3 years ago

The error is related to the pickle protocol version in your Python installation. I had version 5 and, since the assertion in line 279 of dnnlib/tflib/network.py checks for versions 2, 3 and 4, I simply added 5 in there and I was able to use custom style weights.

Hope this helps!

dogadikbayir commented 3 years ago

@uhapppy I think you might be looking at the wrong file. in your original reply:

i was only able to use the asbtract photo style every other style give me this error

Downloading my little pony weights (This may take a while)... Download complete Traceback (most recent call last): File "c:/Users/JF/Desktop/music/music.py", line 10, in <module> L.hallucinate(file_name = 'hills_pony.mp4') File "C:\Users\JF\AppData\Local\Programs\Python\Python37\lib\site-packages\lucidsonicdreams\main.py", line 636, in hallucinate self.stylegan_init() File "C:\Users\JF\AppData\Local\Programs\Python\Python37\lib\site-packages\lucidsonicdreams\main.py", line 126, in stylegan_init self.Gs = pickle.load(f)[2] File "C:\Users\JF\AppData\Local\Programs\Python\Python37\lib\site-packages\dnnlib\tflib\network.py", line 279, in __setstate__ assert state["version"] in [2, 3] AssertionError

the error message indicates line 279 in the network.py file (File "C:\Users\JF\AppData\Local\Programs\Python\Python37\lib\site-packages\dnnlib\tflib\network.py", line 279, in __setstate__ assert state["version"] in [2, 3] AssertionError). You need to change that line to assert state["version"] in [2, 3, 4, 5] (depending on your pickle protocol version, I added both 4 and 5 here since your version of network.py seems to only have 2 and 3).

uhapppy commented 3 years ago

actually i check and the original function is ` def setstate(self, state: dict) -> None: """Pickle import."""

    # Execute custom import handlers.
    for handler in _import_handlers:
        state = handler(state)

    # Get basic fields.
    assert state["version"] in [2, 3, 4, 5]
    name = state["name"]
    static_kwargs = state["static_kwargs"]
    build_module_src = state["build_module_src"]
    build_func_name = state["build_func_name"]`
dogadikbayir commented 3 years ago

@uhapppy okay, so if the error is still AssertionError, it means that your state['version'] value is not in array [2, 3, 4, 5]. You can insert print(state["version"]) right before the assertion to see which version you have and then insert that value to the array in the next line. this way, you are guaranteed to get rid of the AssertionError, which is the original error in this issue. In my case, it did not break anything and I was able to use custom weights.

dogadikbayir commented 3 years ago

@uhapppy can you please share the error message you are getting right now?

masterofshapes commented 3 years ago

Hmm that didnt fix for me either Im geting this error Traceback (most recent call last): File "lucid.py", line 18, in flash_strength = 0.7) File "C:\Python37\lib\site-packages\lucidsonicdreams\main.py", line 680, in hallucinate self.generate_frames() File "C:\Python37\lib\site-packages\lucidsonicdreams\main.py", line 525, in generate_frames np.tile(class_batch, (batch_size, 1))) File "C:\Python37\lib\site-packages\dnnlib\tflib\network.py", line 604, in run out_gpu = net_gpu.get_output_for(*in_gpu, return_as_list=True, **dynamic_kwargs) File "C:\Python37\lib\site-packages\dnnlib\tflib\network.py", line 350, in get_output_for self._get_vars() # ensure that all variables have been created File "C:\Python37\lib\site-packages\dnnlib\tflib\network.py", line 297, in _get_vars self._vars = OrderedDict(self._get_own_vars()) File "C:\Python37\lib\site-packages\dnnlib\tflib\network.py", line 286, in _get_own_vars self._init_graph() File "C:\Python37\lib\site-packages\dnnlib\tflib\network.py", line 126, in _init_graph assert self._input_templates is None AssertionError

uhapppy commented 3 years ago

@dogadikbayir i manage to figure it out i add version 5 to the assert state(seem like the network.py that i open file was not the right one ) but i get still get an error and now it is File "c:/Users/JF/Desktop/music/music.py", line 10, in <module> L.hallucinate(file_name = 'hours2.mp4') File "C:\Users\JF\AppData\Local\Programs\Python\Python37\lib\site-packages\lucidsonicdreams\main.py", line 636, in hallucinate self.stylegan_init() File "C:\Users\JF\AppData\Local\Programs\Python\Python37\lib\site-packages\lucidsonicdreams\main.py", line 126, in stylegan_init self.Gs = pickle.load(f)[2] File "C:\Users\JF\AppData\Local\Programs\Python\Python37\lib\site-packages\dnnlib\tflib\network.py", line 291, in __setstate__ exec(self._build_module_src, module.__dict__) # pylint: disable=exec-used File "<string>", line 13, in <module> ModuleNotFoundError: No module named 'dnnlib.tflib.ops'

dogadikbayir commented 3 years ago

@masterofshapes I could not find the assert self._input_templates is None line in my version of network.py, so I think we are using different versions of dnnlib. I used the dnnlib in this repository. You could try to clone the stylegan2-ada repo in the link into C:\Python37\lib\site-packages/lucidsonicdreams/stylegan2 and you could replace C:\Python37\lib\site-packages\dnnlib with the dnnlib folder inside the cloned repo.

@uhapppy I think your problem could also be related to the dnnlib version you are using, you could try the same procedure I've described above.

If this does not work out for you guys, I think it could be a Windows related bug, I am using Linux.

Hope this helps!

uhapppy commented 3 years ago

@dogadikbayir i did everything you said it get me farter this time the code work until it reach the hallucinating part now i get this error Traceback (most recent call last): File "c:/Users/JF/Desktop/music/music.py", line 10, in <module> L.hallucinate(file_name = 'hours2.mp4') File "C:\Users\JF\AppData\Local\Programs\Python\Python37\lib\site-packages\lucidsonicdreams\main.py", line 680, in hallucinate self.generate_frames() File "C:\Users\JF\AppData\Local\Programs\Python\Python37\lib\site-packages\lucidsonicdreams\main.py", line 525, in generate_frames np.tile(class_batch, (batch_size, 1))) File "C:\Users\JF\AppData\Local\Programs\Python\Python37\lib\site-packages\dnnlib\tflib\network.py", line 604, in run out_gpu = net_gpu.get_output_for(*in_gpu, return_as_list=True, **dynamic_kwargs) File "C:\Users\JF\AppData\Local\Programs\Python\Python37\lib\site-packages\dnnlib\tflib\network.py", line 350, in get_output_for self._get_vars() # ensure that all variables have been created File "C:\Users\JF\AppData\Local\Programs\Python\Python37\lib\site-packages\dnnlib\tflib\network.py", line 297, in _get_vars self._vars = OrderedDict(self._get_own_vars()) File "C:\Users\JF\AppData\Local\Programs\Python\Python37\lib\site-packages\dnnlib\tflib\network.py", line 286, in _get_own_vars self._init_graph() File "C:\Users\JF\AppData\Local\Programs\Python\Python37\lib\site-packages\dnnlib\tflib\network.py", line 126, in _init_graph assert self._input_templates is None AssertionError

dogadikbayir commented 3 years ago

@masterofshapes @uhapppy my bad, I found the assertion, for self._input_templates in my version too. in this case, I need to reproduce the problem on my own machine to help you guys out further. however, the new error is also an AssertionError and it is caused because the self._input_templates property of the class is not None at the time of the assertion. In my case it is None so I am not getting the error. you could trace the value of self._input_templates to find the place where it is being set to a value other than None.

uhapppy commented 3 years ago

@dogadikbayir good tanks you very much for your time let us know if you find something

IvonaTau commented 3 years ago

FYI I had the same AssertionError which happened because I had stylegan2-ada folder in the same location where I installed lucid sonic dreams.

I run pip uninstall lucidsonicdreams Created a new folder Run pip install lucidsonicdreams

and it worked with custom models.