cc-ai / climategan

Code and pre-trained model for the algorithm generating visualisations of 3 climate change related events: floods, wildfires and smog.
https://thisclimatedoesnotexist.com
GNU General Public License v3.0
72 stars 18 forks source link

current master does not work when the task is msd instead of msdp #184

Closed tianyu-z closed 3 years ago

tianyu-z commented 3 years ago

File "train.py", line 188, in main() File "/home/mila/t/tianyu.zhang/myenv/lib/python3.7/site-packages/hydra/main.py", line 24, in decorated_main strict=strict, File "/home/mila/t/tianyu.zhang/myenv/lib/python3.7/site-packages/hydra/_internal/utils.py", line 174, in run_hydra overrides=args.overrides, File "/home/mila/t/tianyu.zhang/myenv/lib/python3.7/site-packages/hydra/_internal/hydra.py", line 86, in run job_subdir_key=None, File "/home/mila/t/tianyu.zhang/myenv/lib/python3.7/site-packages/hydra/plugins/common/utils.py", line 109, in run_job ret.return_value = task_function(task_cfg) File "train.py", line 175, in main trainer.setup() File "/home/mila/t/tianyu.zhang/omnigan/omnigan/trainer.py", line 776, in setup self.input_shapes = self.compute_input_shapes() File "/home/mila/t/tianyu.zhang/omnigan/omnigan/trainer.py", line 676, in compute_input_shapes .dataset[0]["data"] File "/home/mila/t/tianyu.zhang/omnigan/omnigan/data.py", line 459, in getitem for task, path in paths.items() File "/home/mila/t/tianyu.zhang/myenv/lib/python3.7/site-packages/torchvision/transforms/transforms.py", line 61, in call img = t(img) File "/home/mila/t/tianyu.zhang/omnigan/omnigan/transforms.py", line 235, in call for task, tensor in data.items() File "/home/mila/t/tianyu.zhang/omnigan/omnigan/transforms.py", line 235, in for task, tensor in data.items() File "/home/mila/t/tianyu.zhang/omnigan/omnigan/transforms.py", line 355, in rand_saturation tensor = adjust_saturation(tensor, saturation_factor=factor) File "/home/mila/t/tianyu.zhang/myenv/lib/python3.7/site-packages/torchvision/transforms/functional.py", line 746, in adjust_saturation return F_t.adjust_saturation(img, saturation_factor) File "/home/mila/t/tianyu.zhang/myenv/lib/python3.7/site-packages/torchvision/transforms/functional_tensor.py", line 185, in adjust_saturation return _blend(img, rgb_to_grayscale(img), saturation_factor) File "/home/mila/t/tianyu.zhang/myenv/lib/python3.7/site-packages/torchvision/transforms/functional_tensor.py", line 76, in rgb_to_grayscale raise TypeError('Input Image does not contain 3 Channels') TypeError: Input Image does not contain 3 Channels

vict0rsch commented 3 years ago

did you try debugging? like what's the shape of the tensor? can you get its path somehow?

tianyu-z commented 3 years ago

@vict0rsch sorry I haven't try debugging. I will have time to do it on Wednesday (tomorrow). Alexia said she does not have the issue. I guess maybe there is something wrong from my side.

tianyu-z commented 3 years ago

Btw, the config file I used is the exact defaults.yaml except for the change of the task in the task list.

tianyu-z commented 3 years ago

@vict0rsch The error no longer exists after I upgrade pytorch from 1.6.0 to 1.7.1. The issue is: In 1.6.0, we have:

def rgb_to_grayscale(img):
    # type: (Tensor) -> Tensor
    """Convert the given RGB Image Tensor to Grayscale.
    For RGB to Grayscale conversion, ITU-R 601-2 luma transform is performed which
    is L = R * 0.2989 + G * 0.5870 + B * 0.1140
    Args:
        img (Tensor): Image to be converted to Grayscale in the form [C, H, W].
    Returns:
        Tensor: Grayscale image.
    """
    if img.shape[0] != 3:
        raise TypeError('Input Image does not contain 3 Channels')
    return (0.2989 * img[0] + 0.5870 * img[1] + 0.1140 * img[2]).to(img.dtype)

The img, we have has shape of [1,3,640,640], so img.shape[0]!=3 and gives the error

vict0rsch commented 3 years ago

OK cool 😎