boschresearch / one-shot-synthesis

Official PyTorch implementation of the paper "Generating Novel Scene Compositions from Single Images and Videos"
GNU Affero General Public License v3.0
40 stars 14 forks source link

cannot reproduce results in Colab session #4

Closed carloelle closed 4 months ago

carloelle commented 1 year ago

Hi,

when I try to reproduce your results using your sample data in Colab, by running the command:

!python /content/drive/MyDrive/OstuniLab/Resolve/one-shot-synthesis-master/train.py --exp_name Osmis_trial --use_kornia_augm --prob_augm 0.7 --dataset /content/drive/MyDrive/OstuniLab/Resolve/one-shot-synthesis-master/datasets/example_image --num_epochs 150000 --max_size 330

I get the following error:

Created a dataset of size = 1 with image resolution (192, 320)
Using the training regime *with* segmentation masks
/usr/local/lib/python3.9/site-packages/torch/utils/data/dataloader.py:561: UserWarning: This DataLoader will create 8 worker processes in total. Our suggested max number of worker in current system is 2, which is smaller than what this DataLoader is going to create. Please be aware that excessive worker creation might get DataLoader running slow or even freeze, lower the worker number to avoid potential slowness/freeze if necessary.
  warnings.warn(_create_warning_msg(
Created Generator with 5887448 parameters
Created Discriminator (3+4 blocks) with 2443581 parameters
Traceback (most recent call last):
  File "/content/drive/MyDrive/OstuniLab/Resolve/one-shot-synthesis-master/train.py", line 42, in <module>
    batch = diff_augment(batch)
  File "/content/drive/MyDrive/OstuniLab/Resolve/one-shot-synthesis-master/core/differentiable_augmentation/diff_augm.py", line 12, in __call__
    return self.augment_func(batch)
  File "/usr/local/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/content/drive/MyDrive/OstuniLab/Resolve/one-shot-synthesis-master/core/differentiable_augmentation/AugmentPipe_kornia.py", line 54, in forward
    x[i] = tr(x[i])
  File "/usr/local/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/kornia/augmentation/base.py", line 212, in forward
    output = self.apply_func(in_tensor, params, flags)
  File "/usr/local/lib/python3.9/site-packages/kornia/augmentation/_2d/base.py", line 126, in apply_func
    output = self.transform_inputs(in_tensor, params, flags, trans_matrix)
  File "/usr/local/lib/python3.9/site-packages/kornia/augmentation/base.py", line 263, in transform_inputs
    output = self.apply_transform(in_tensor, params, flags, transform=transform)
  File "/usr/local/lib/python3.9/site-packages/kornia/augmentation/_2d/geometric/center_crop.py", line 111, in apply_transform
    return crop_by_indices(input, params["src"], flags["size"])
  File "/usr/local/lib/python3.9/site-packages/kornia/geometry/transform/crop2d.py", line 330, in crop_by_indices
    return resize(
  File "/usr/local/lib/python3.9/site-packages/kornia/utils/image.py", line 229, in _wrapper
    output = f(input, *args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/kornia/geometry/transform/affwarp.py", line 600, in resize
    output = torch.nn.functional.interpolate(input, size=size, mode=interpolation, align_corners=align_corners)
  File "/usr/local/lib/python3.9/site-packages/torch/nn/functional.py", line 3959, in interpolate
    return torch._C._nn.upsample_bilinear2d(input, output_size, align_corners, scale_factors)
TypeError: upsample_bilinear2d() received an invalid combination of arguments - got (Tensor, tuple, bool, NoneType), but expected one of:
 * (Tensor input, tuple of ints output_size, bool align_corners, tuple of floats scale_factors)
      didn't match because some of the arguments have invalid types: (Tensor, tuple of (float, float), bool, NoneType)
 * (Tensor input, tuple of ints output_size, bool align_corners, float scales_h, float scales_w, *, Tensor out)

also: when I try to use my own data, by running:

!python /content/drive/MyDrive/OstuniLab/Resolve/one-shot-synthesis-master/train.py --exp_name OsmisCellSeg --use_kornia_augm --prob_augm 0.7 --dataset /content/drive/MyDrive/OstuniLab/Resolve/one-shot-synthesis-master/datasets/cellsegmentation --num_epochs 150000 --max_size 500

I get the following error:

Created a dataset of size = 1 with image resolution (512, 512)
Using the training regime *with* segmentation masks
/usr/local/lib/python3.9/site-packages/torch/utils/data/dataloader.py:561: UserWarning: This DataLoader will create 8 worker processes in total. Our suggested max number of worker in current system is 2, which is smaller than what this DataLoader is going to create. Please be aware that excessive worker creation might get DataLoader running slow or even freeze, lower the worker number to avoid potential slowness/freeze if necessary.
  warnings.warn(_create_warning_msg(
Created Generator with 7156154 parameters
Created Discriminator (4+3 blocks) with 3243680 parameters
Traceback (most recent call last):
  File "/content/drive/MyDrive/OstuniLab/Resolve/one-shot-synthesis-master/train.py", line 33, in <module>
    out_G = diff_augment(out_G)
  File "/content/drive/MyDrive/OstuniLab/Resolve/one-shot-synthesis-master/core/differentiable_augmentation/diff_augm.py", line 12, in __call__
    return self.augment_func(batch)
  File "/usr/local/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/content/drive/MyDrive/OstuniLab/Resolve/one-shot-synthesis-master/core/differentiable_augmentation/AugmentPipe_kornia.py", line 54, in forward
    x[i] = tr(x[i])
  File "/usr/local/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/kornia/augmentation/base.py", line 212, in forward
    output = self.apply_func(in_tensor, params, flags)
  File "/usr/local/lib/python3.9/site-packages/kornia/augmentation/_2d/base.py", line 126, in apply_func
    output = self.transform_inputs(in_tensor, params, flags, trans_matrix)
  File "/usr/local/lib/python3.9/site-packages/kornia/augmentation/base.py", line 263, in transform_inputs
    output = self.apply_transform(in_tensor, params, flags, transform=transform)
  File "/usr/local/lib/python3.9/site-packages/kornia/augmentation/_2d/geometric/center_crop.py", line 111, in apply_transform
    return crop_by_indices(input, params["src"], flags["size"])
  File "/usr/local/lib/python3.9/site-packages/kornia/geometry/transform/crop2d.py", line 330, in crop_by_indices
    return resize(
  File "/usr/local/lib/python3.9/site-packages/kornia/utils/image.py", line 229, in _wrapper
    output = f(input, *args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/kornia/geometry/transform/affwarp.py", line 600, in resize
    output = torch.nn.functional.interpolate(input, size=size, mode=interpolation, align_corners=align_corners)
  File "/usr/local/lib/python3.9/site-packages/torch/nn/functional.py", line 3959, in interpolate
    return torch._C._nn.upsample_bilinear2d(input, output_size, align_corners, scale_factors)
TypeError: upsample_bilinear2d() received an invalid combination of arguments - got (Tensor, tuple, bool, NoneType), but expected one of:
 * (Tensor input, tuple of ints output_size, bool align_corners, tuple of floats scale_factors)
      didn't match because some of the arguments have invalid types: (Tensor, tuple of (float, float), bool, NoneType)
 * (Tensor input, tuple of ints output_size, bool align_corners, float scales_h, float scales_w, *, Tensor out)

any idea how to resolve the issue?

best, carlo

SushkoVadim commented 1 year ago

Hi Carlo,

This problem occurs when an incorrect version of Kornia is used. I think I observed such issues with kornia==0.6.0. I recommend installing the packages from environment.yml, for which our code was tested.

Regards, Vadim