Closed huangbinz closed 2 years ago
Hi,
thank you for your interest in MonoRec.
I don't have this bug on my machine. Could you please let me know which version of the torchvision
package you are using?
If possible, downgrade torchvision
to version 0.6
.
I think this should do the trick without downgrading your torchvision
.
class ColorJitterMulti(torchvision.transforms.ColorJitter):
def fix_transform(self):
self.params = self.get_params(self.brightness, self.contrast, self.saturation, self.hue)
def __call__(self, img):
fn_idx, brightness_factor, contrast_factor, saturation_factor, hue_factor = self.params
for fn_id in fn_idx:
if fn_id == 0 and brightness_factor is not None:
img = F.adjust_brightness(img, brightness_factor)
elif fn_id == 1 and contrast_factor is not None:
img = F.adjust_contrast(img, contrast_factor)
elif fn_id == 2 and saturation_factor is not None:
img = F.adjust_saturation(img, saturation_factor)
elif fn_id == 3 and hue_factor is not None:
img = F.adjust_hue(img, hue_factor)
return img
Hi, thank you for your interest in MonoRec. I don't have this bug on my machine. Could you please let me know which version of the
torchvision
package you are using? If possible, downgradetorchvision
to version0.6
.
thank you for your reply, my torchvision is 0.9.0.
I think this should do the trick without downgrading your
torchvision
.class ColorJitterMulti(torchvision.transforms.ColorJitter): def fix_transform(self): self.params = self.get_params(self.brightness, self.contrast, self.saturation, self.hue) def __call__(self, img): fn_idx, brightness_factor, contrast_factor, saturation_factor, hue_factor = self.params for fn_id in fn_idx: if fn_id == 0 and brightness_factor is not None: img = F.adjust_brightness(img, brightness_factor) elif fn_id == 1 and contrast_factor is not None: img = F.adjust_contrast(img, contrast_factor) elif fn_id == 2 and saturation_factor is not None: img = F.adjust_saturation(img, saturation_factor) elif fn_id == 3 and hue_factor is not None: img = F.adjust_hue(img, hue_factor) return img
you are right, but i think, this is the implementation in ColorJitter.forward
, we can call it directly
The implementation is very similar. However, ColorJitter.forward
obtains new randomized parameters every time it is called.
In our case, this is not desired because we need to apply the same augmentation onto all the frames that go into the cost volume.
Therefore, we fix the parameters once (in fix_transform
) and then reuse the same parameters for all frames in the respective cost volume. (fix_transform
gets called once for every item the dataset returns).
I understand, thank you very much for your patience
when train the model with command
python train.py --config configs/train/monorec/monorec_depth.json --options stereo
, get an error:modify function in
kitti_odometry_dataset.py
from:to
can fix this error
this is a bug? is it right to modify the code like this?