Skip to content
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

Feature: Play with Covariance instead of Gram? #11

Open
ghost opened this issue Jan 25, 2019 · 0 comments
Open

Feature: Play with Covariance instead of Gram? #11

ghost opened this issue Jan 25, 2019 · 0 comments

Comments

@ghost
Copy link

ghost commented Jan 25, 2019

I watched a presentation from Artomatix and they have some arguments for using a covariance loss instead of a gram loss. You can flip between the two (I think it's correct..) by doing

class GramMatrix(nn.Module):

    def forward(self, input):
        B, C, H, W = input.size()
        x_flat = input.view(C, H * W)

        #Add this for covariance loss
        x_flat = x_flat - x_flat.mean(1).unsqueeze(1)

        return torch.mm(x_flat, x_flat.t())

I didn't experiment with it much, but using the default content/style at 1024, you get these:
Gram Loss:
gram

Covariance Loss:
cov

I wouldn't say it's better, but it is interesting it adds more texture to the sky. Might have some utility for more textured styles?

Thoughts?

p.s. Nice implementation! Happy there's a true to jcjohson, cuda 10, pytorch impl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants