question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`Model [Palette() form models.model] not recognized`, installation inside `conda` environment

See original GitHub issue

setup

Running on Windows Subsystem for Linux 2 (WSL2).

git clone https://github.com/Janspiry/Palette-Image-to-Image-Diffusion-Models.git
cd Palette-Image-to-Image-Diffusion-Models

conda installation per #20

command

python run.py -p train -c config/inpainting_celebahq_dummy.json --debug

inpainting_celebahq_dummy.json

{
    "name": "inpainting_celebahq", // experiments name
    "gpu_ids": [
        0
    ], // gpu ids list, default is single 0
    "seed": -1, // random seed, seed <0 represents randomization not used 
    "finetune_norm": false, // find the parameters to optimize
    "path": { //set every part file path
        "base_dir": "experiments", // base path for all log except resume_state
        "code": "code", // code backup
        "tb_logger": "tb_logger", // path of tensorboard logger
        "results": "results",
        "checkpoint": "checkpoint",
        "resume_state": "experiments/train_inpainting_celebahq_220426_233652/checkpoint/190"
        // "resume_state": null // ex: 100, loading .state  and .pth from given epoch and iteration
    },
    "datasets": { // train or test
        "train": {
            "which_dataset": { // import designated dataset using arguments 
                "name": [
                    "data.dataset",
                    "InpaintDataset"
                ], // import Dataset() class / function(not recommend) from data.dataset.py (default is [data.dataset.py])
                "args": { // arguments to initialize dataset
                    "data_root": "datasets/celebahq_dummy/flist/train.flist",
                    "data_len": -1,
                    "mask_config": {
                        "mask_mode": "hybrid"
                    }
                }
            },
            "dataloader": {
                "validation_split": 2, // percent or number 
                "args": { // arguments to initialize train_dataloader
                    "batch_size": 3, // batch size in each gpu
                    "num_workers": 4,
                    "shuffle": true,
                    "pin_memory": true,
                    "drop_last": true
                },
                "val_args": { // arguments to initialize valid_dataloader, will overwrite the parameters in train_dataloader
                    "batch_size": 1, // batch size in each gpu
                    "num_workers": 4,
                    "shuffle": false,
                    "pin_memory": true,
                    "drop_last": false
                }
            }
        },
        "test": {
            "which_dataset": {
                "name": "InpaintDataset", // import Dataset() class / function(not recommend) from default file
                "args": {
                    "data_root": "datasets/celebahq_dummy/flist/test.flist",
                    "mask_config": {
                        "mask_mode": "center"
                    }
                }
            },
            "dataloader": {
                "args": {
                    "batch_size": 8,
                    "num_workers": 4,
                    "pin_memory": true
                }
            }
        }
    },
    "model": { // networks/metrics/losses/optimizers/lr_schedulers is a list and model is a dict
        "which_model": { // import designated  model(trainer) using arguments 
            "name": [
                "models.model",
                "Palette"
            ], // import Model() class / function(not recommend) from models.model.py (default is [models.model.py])
            "args": {
                "sample_num": 8, // process of each image
                "task": "inpainting",
                "ema_scheduler": {
                    "ema_start": 1,
                    "ema_iter": 1,
                    "ema_decay": 0.9999
                },
                "optimizers": [
                    {
                        "lr": 5e-5,
                        "weight_decay": 0
                    }
                ]
            }
        },
        "which_networks": [ // import designated list of networks using arguments
            {
                "name": [
                    "models.network",
                    "Network"
                ], // import Network() class / function(not recommend) from default file (default is [models/network.py]) 
                "args": { // arguments to initialize network
                    "init_type": "kaiming", // method can be [normal | xavier| xavier_uniform | kaiming | orthogonal], default is kaiming
                    "module_name": "guided_diffusion", // sr3 | guided_diffusion
                    "unet": {
                        "in_channel": 6,
                        "out_channel": 3,
                        "inner_channel": 64,
                        "channel_mults": [
                            1,
                            2,
                            4,
                            8
                        ],
                        "attn_res": [
                            // 32,
                            16
                            // 8
                        ],
                        "num_head_channels": 32,
                        "res_blocks": 2,
                        "dropout": 0.2,
                        "image_size": 256
                    },
                    "beta_schedule": {
                        "train": {
                            "schedule": "linear",
                            "n_timestep": 2000,
                            // "n_timestep": 10, // debug
                            "linear_start": 1e-6,
                            "linear_end": 0.01
                        },
                        "test": {
                            "schedule": "linear",
                            "n_timestep": 1000,
                            "linear_start": 1e-4,
                            "linear_end": 0.09
                        }
                    }
                }
            }
        ],
        "which_losses": [ // import designated list of losses without arguments
            "mse_loss" // import mse_loss() function/class from default file (default is [models/losses.py]), equivalent to { "name": "mse_loss", "args":{}}
        ],
        "which_metrics": [ // import designated list of metrics without arguments
            "mae" // import mae() function/class from default file (default is [models/metrics.py]), equivalent to { "name": "mae", "args":{}}
        ]
    },
    "train": { // arguments for basic training
        "n_epoch": 1e8, // max epochs, not limited now
        "n_iter": 1e8, // max interations
        "val_epoch": 5, // valdation every specified number of epochs
        "save_checkpoint_epoch": 10,
        "log_iter": 1e3, // log every specified number of iterations
        "tensorboard": true // tensorboardX enable
    },
    "debug": { // arguments in debug mode, which will replace arguments in train
        "val_epoch": 1,
        "save_checkpoint_epoch": 1,
        "log_iter": 2,
        "debug_split": 50 // percent or number, change the size of dataloder to debug_split.
    }
}

Directory Structure

image

Error

Exception has occurred: NotImplementedError       (note: full exception trace is shown but execution is paused at: _run_module_as_main)
Model [Palette() form models.model] not recognized.
  File "/home/sgbaird/GitHub/Palette-Image-to-Image-Diffusion-Models/core/praser.py", line 41, in init_obj
    ret = attr(*args, **kwargs)
  File "/home/sgbaird/GitHub/Palette-Image-to-Image-Diffusion-Models/models/model.py", line 49, in __init__
    self.netG.set_new_noise_schedule(phase=self.phase)
  File "/home/sgbaird/GitHub/Palette-Image-to-Image-Diffusion-Models/models/network.py", line 36, in set_new_noise_schedule
    self.register_buffer('gammas', to_torch(gammas))
  File "/home/sgbaird/miniconda3/envs/palette/lib/python3.9/site-packages/torch/cuda/__init__.py", line 166, in _lazy_init
    raise AssertionError("Torch not compiled with CUDA enabled")

During handling of the above exception, another exception occurred:

  File "/home/sgbaird/GitHub/Palette-Image-to-Image-Diffusion-Models/core/praser.py", line 49, in init_obj
    raise NotImplementedError('{} [{:s}() form {:s}] not recognized.'.format(init_type, class_name, file_name))
  File "/home/sgbaird/GitHub/Palette-Image-to-Image-Diffusion-Models/models/__init__.py", line 10, in create_model
    model = init_obj(model_opt, logger, default_file_name='models.model', init_type='Model')
  File "/home/sgbaird/GitHub/Palette-Image-to-Image-Diffusion-Models/run.py", line 44, in main_worker
    model = create_model(
  File "/home/sgbaird/GitHub/Palette-Image-to-Image-Diffusion-Models/run.py", line 92, in <module>
    main_worker(0, 1, opt)
  File "/home/sgbaird/miniconda3/envs/palette/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/sgbaird/miniconda3/envs/palette/lib/python3.9/runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/home/sgbaird/miniconda3/envs/palette/lib/python3.9/runpy.py", line 268, in run_path
    return _run_module_code(code, init_globals, run_name,
  File "/home/sgbaird/miniconda3/envs/palette/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/sgbaird/miniconda3/envs/palette/lib/python3.9/runpy.py", line 197, in _run_module_as_main (Current frame)
    return _run_code(code, main_globals, None,

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Janspirycommented, Jul 22, 2022

Feel free to reopen the issue if there is any question.

1reaction
luislofer89commented, Jun 20, 2022

I’m having the same issue with the current status of “master” branch. Commit “https://github.com/Janspiry/Palette-Image-to-Image-Diffusion-Models/tree/d1b9b010edeee177aaa15850002766e370a8307b” is working fine for me. A bug was probably introduced in commit “ed29b1ce9ff2ae41791d52642004385886f0680f”

Read more comments on GitHub >

github_iconTop Results From Across the Web

VS Code not detecting package in conda environment
Open the command palette (Ctrl + Shift + P in linux) · Type > Python select interpreter and press enter · Paste the...
Read more >
Python and Django tutorial in Visual Studio Code
Python Django tutorial demonstrating IntelliSense, code navigation, and debugging for both code and templates in Visual Studio Code, the best Python IDE.
Read more >
Managing environments - Conda
With conda, you can create, export, list, remove, and update environments that have different versions of Python and/or packages installed in them.
Read more >
How to Setup Your Python Environment for Machine Learning ...
In this tutorial, you will discover how to set up a Python machine learning development environment using Anaconda.
Read more >
Guide to Conda for TensorFlow and PyTorch
However, pip and conda don't always play nice together. The primary issue is that conda is not able to control packages that it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found