Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Exception: Could not find configuration default.json in HyperGAN #285

Open
Konradoslaw opened this issue Oct 31, 2020 · 3 comments
Open
Labels

Comments

@Konradoslaw
Copy link

Hello, I am trying to test and learn how to use HyperGAn on my PC. I've installed it using the pip install hypergan command on my anaconda environment with python 3.7 on Windows10.

Next I've tried to use this testing command: hypergan train preset:celeba -s 128x128x3 but I've got this error: 'hypergan' is not recognized as an internal or external command

Turns out, that for some reason pip still does not add the hypergan.cmd file during Installation and I had to add it manually.

After that I needed to install some libraries that are listet at the end of the HyperGAN git page (like semantic).

Finally when typing again the train command I get this error:

(gantest) C:\Users\Konradeu>hypergan train preset:celeba -s 128x128x3
Traceback (most recent call last):
File "C:\Users\Konradeu\anaconda3\envs\gantest\Scripts\hypergan", line 90, in
config_filename = hg.Configuration.find(config_name, config_format=config_format)
File "C:\Users\Konradeu\anaconda3\envs\gantest\lib\site-packages\hypergan\configuration.py", line 29, in find
raise Exception(message)
Exception: Could not find configuration default.json
Error detected, HyperGAN exiting

But the file is present in C:\Users\Konradeu\anaconda3\envs\gantest\lib\site-packages\hypergan\configurations directory.
When I type (command for testing whether the Installation was successful): hypergan new . -l
i get the following errors:

(gantest) C:\Users\Konradeu>hypergan new . -l
default
C:\Users\Konradeu\anaconda3\envs\gantest\lib\site-packages\hypergan\configurations\aligned_interpolated - Could not find configuration C:\Users\Konradeu\anaconda3\envs\gantest\lib\site-packages\hypergan\configurations\aligned_interpolated.json(error)
C:\Users\Konradeu\anaconda3\envs\gantest\lib\site-packages\hypergan\configurations\classification - Could not find configuration C:\Users\Konradeu\anaconda3\envs\gantest\lib\site-packages\hypergan\configurations\classification.json(error)
C:\Users\Konradeu\anaconda3\envs\gantest\lib\site-packages\hypergan\configurations\colorizer - Could not find configuration C:\Users\Konradeu\anaconda3\envs\gantest\lib\site-packages\hypergan\configurations\colorizer.json(error)
C:\Users\Konradeu\anaconda3\envs\gantest\lib\site-packages\hypergan\configurations\configurable - Could not find configuration C:\Users\Konradeu\anaconda3\envs\gantest\lib\site-packages\hypergan\configurations\configurable.json(error)
C:\Users\Konradeu\anaconda3\envs\gantest\lib\site-packages\hypergan\configurations\dcgan - Could not find configuration C:\Users\Konradeu\anaconda3\envs\gantest\lib\site-packages\hypergan\configurations\dcgan.json(error)
C:\Users\Konradeu\anaconda3\envs\gantest\lib\site-packages\hypergan\configurations\default - Could not find configuration C:\Users\Konradeu\anaconda3\envs\gantest\lib\site-packages\hypergan\configurations\default.json(error)
C:\Users\Konradeu\anaconda3\envs\gantest\lib\site-packages\hypergan\configurations\model_scaling - Could not find configuration C:\Users\Konradeu\anaconda3\envs\gantest\lib\site-packages\hypergan\configurations\model_scaling.json(error)
C:\Users\Konradeu\anaconda3\envs\gantest\lib\site-packages\hypergan\configurations\stylegan - Could not find configuration C:\Users\Konradeu\anaconda3\envs\gantest\lib\site-packages\hypergan\configurations\stylegan.json(error)

To conclude, all of these files, that the hypergan software can't find, are present in the configurations directory. For some reason, hypergan does not see them or is pointing at wrong location. I am not sure whether it is a problem of windows OS or something else. On the discord support channel I've seen, that other people had the same issue.

@Konradoslaw Konradoslaw changed the title [BUG] [BUG] Exception: Could not find configuration default.json in HyperGAN Oct 31, 2020
@apachidesigns
Copy link

apachidesigns commented Oct 31, 2020

I have the same issue in Ubuntu 20.04.1 LTS and Python 3.8.
Ran "pip install hypergan" within a conda environment followed by pip install hyperchamber, torch, torchvision & semantic_version
Running "hypergan train preset:celeba -s 128x128x3" resulted in:

Traceback (most recent call last):
File "/home/alan/miniconda3/bin/hypergan", line 90, in
config_filename = hg.Configuration.find(config_name, config_format=config_format)
File "/home/alan/miniconda3/lib/python3.8/site-packages/hypergan/configuration.py", line 29, in find
raise Exception(message)
Exception: Could not find configuration default.json
Error detected, HyperGAN exiting

Tried a second time, outside of a conda environment
pip install hypergan, followed by setting up Pytorch using pip3 (varhowto.com/install-pytorch-ubuntu-20-04)
Checked that Pytorch was installed and could "see" Cuda (import torch; torch.cuda.is_available()) followed by "hypergan train preset:celeba -s 128x128x3" resulted in same error as before

Traceback (most recent call last):
File "/home/alan/miniconda3/bin/hypergan", line 90, in
config_filename = hg.Configuration.find(config_name, config_format=config_format)
File "/home/alan/miniconda3/lib/python3.8/site-packages/hypergan/configuration.py", line 29, in find
raise Exception(message)
Exception: Could not find configuration default.json
Error detected, HyperGAN exiting

@Konradoslaw
Copy link
Author

Hello again,

after a few days of searching trough the python files in hypergan and great help from my much more experienced Friend i finally found a temporary solution.

In the configuration.py file, located in C:\Users\Konradeu\anaconda3\envs\gantest\Lib\site-packages\hypergan folder, the method all_paths takes the argument prepackaged.

And here is the problem. The prepackaged argument/object is either never parsed to the all_paths method, or it has a wrong value. When I try to print the value of it, I get False.

Therefore the first if statement will never get a True value, and hence the paths list will not receive the correct paths to the configurations folder at all.

To workaround it, I added in the 9th line "or True" to the if statement. The whole definition looks something like this:

def all_paths(prepackaged):
    print(prepackaged)
    paths = [ os.path.abspath(os.path.relpath("."))+"/" ]
    if prepackaged or True:      #here is the change
        paths = [
                 os.path.dirname(os.path.realpath(__file__)) + "/configurations/",
                 os.path.abspath(os.path.expanduser('~/.hypergan/configs/'))+'/'
                ]
    return paths

As I said, it's just a temporary solution that enabled me to finally run some training in hypergan.
Hope this will help someone :)

@apachidesigns
Copy link

apachidesigns commented Nov 7, 2020

Hello Konradoslaw
Thanks for your suggestion. It does work but your suggestion has caused me to have a look at this problem myself (should have done so earlier)
The root cause of the problem appears to be the following line in the main "hypergan" script (The main hypergan script is located on my p.c. at /home/alan/miniconda3/bin/hypergan)

if args.method != 'new':
   config_filename = hg.Configuration.find(config_name, config_format=config_format)

I have changed the line which finds the configuration file to

if args.method != 'new':
   config_filename = hg.Configuration.find(config_name, config_format=config_format, prepackaged=True)

The new "True" value is passed into configuration.py class "Configuration" and its method "find"
This "True" value for "prepackaged" will be used instead of the default value that is declared for Configuration.find()
And
def find(configuration, verbose=True, config_format='.json', prepackaged=False) #apachidesigns "prepackaged=False" creates a "default" argument to the "find" function
Will instead be called and used at runtime as:
def find(configuration, verbose=True, config_format='.json', prepackaged=True)

This new "True" value for "prepackaged" will be passed through the chain of methods, _find_file() calls all_paths() where it will be used at the point where you made your suggested change

So

def all_paths(prepackaged):
    print(prepackaged)
    paths = [ os.path.abspath(os.path.relpath("."))+"/" ]
    if prepackaged:      #apachidesigns: Don't need to change this
        paths = [
                 os.path.dirname(os.path.realpath(__file__)) + "/configurations/",
                 os.path.abspath(os.path.expanduser('~/.hypergan/configs/'))+'/'
                ]
    return paths

Will now work because the passed down value of "prepackaged" is "True" and the .json config files will be found

Although I think that my suggestion is correct (I do now have hypergan running) I do still consider this suggestion to be a workaround. If I can get time I will try to come up with a more comprehensive solution (and explanation) - My "workaround is no use for anyone who has created and wishes to use their own config file

Hope this is helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants