-
Notifications
You must be signed in to change notification settings - Fork 45
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
water ripple artifacts when using CoBi Loss #3
Comments
@conson0214 |
the loss function in my traning codes as following, i use CoBi_{RGB} as a part of total loss, but i`m wondering if I define it properly? import contextual_loss as cl criterion_rgb = cl.ContextualBilateralLoss(use_vgg=False, loss_type='cosine').to(self.device) criterion_relu1_2 = cl.ContextualBilateralLoss(use_vgg=True, loss_type='cosine', vgg_layer='relu1_2').to(self.device) criterion_relu2_2 = cl.ContextualBilateralLoss(use_vgg=True, loss_type='cosine', vgg_layer='relu2_2').to(self.device) criterion_relu3_4 = cl.ContextualBilateralLoss(use_vgg=True, loss_type='cosine', vgg_layer='relu3_4').to(self.device) l_total = l_cobirgb + l_cobirelu1_2 + l_cobirelu2_2 + 0.5*l_cobirelu3_4 |
The paper uses n×n RGB patches as features for CoBi_RGB. |
How to calculate CoBi_RGB using nxn RGB patches as features? |
It probably means the input of CoBi_RGB should be the vectors of n×n RGB values. For example: # dummy image, shape: (n, c, h, w)
img = torch.rand(n, c, h, w)
# sample patches, shape: (n, c, kernel_size, kernel_size, n_patches)
patches = sample_patches(
img, kernel_size=3, stride=2, padding=0)
# convert to vectors, shape: (n, c*kernel_size*kernel_size, n_patches, 1)
vectors = patches.reshape(n, -1, n_patches, 1)
criterion = ContextualBilateralLoss()
loss = criterion(vectors, vectors) |
Whats the best way to implement this? |
Something like this?
|
@varun19299 maybe This code will help you. |
Yes, this works: modified for including batch size. Thanks for the quick reply. |
Also, with regards to the OOM issue: do you recommend using cosine distance for CoBi RGB too? |
I've tried three types of loss_type, and they all seem to have OOM problem. |
Did you extract patches before applying CoBi/ CX? |
when i training ESRGAN using Contextual Bilateral Loss, without l1/perceptual/GAN loss
![1](https://user-images.githubusercontent.com/27390617/71508838-1fc61e00-28c4-11ea-9347-77367c5a6824.png)
all the inference results seem to have artifacts like water ripple in smooth areas
Do you have any idea how might this artifact come about?
The text was updated successfully, but these errors were encountered: