junjun3518 / alias-free-torch Goto Github PK
View Code? Open in Web Editor NEWSimple torch.nn.module implementation of Alias-Free-GAN style filter and resample
License: Apache License 2.0
Simple torch.nn.module implementation of Alias-Free-GAN style filter and resample
License: Apache License 2.0
padding: bool: True,
should be padding: bool = True,
I'm not sure if this causes an error with every version of PyTorch, but it does with PyTorch 1.12.0+cu113 on Python 3.7.13
In LowPassFilter2d it looks like if self.pad:
should change to if self.padding:
, or self.padding = padding
should change to self.pad = padding
to match LowPassFilter1d.
At this line I believe you wanted torch.special.i1.
Here is a plot of the generated 1D sinc filter kernel.
Here is a plot of the generated 2D jinc filter kernel.
I'd expect it to look more like a series of rings or ripples, rather than a donut or torus.
The FFT output for randn noise put through the 2D filter doesn't look right either.
Changing filter_ = 2 * cutoff * window * jinc(2 * cutoff * time)
to filter_ = 2 * cutoff * window * sinc(2 * cutoff * time)
in kaiser_jinc_filter2d
makes a more familiar kernel.
And the FFT output for randn noise put through this 2D filter looks about how I'd expect.
Hi, thank you very much for the contribution.
I think the new implementation of resample.Upsample1d
and resample.Downsample1d
breaks batched resampling when using groups=C
without expanding the filter to match the shape. Perhaps the implementation should be like the below (maybe similar goes to 2d):
Upsample1d.forward()
# x: [B,C,T]
def forward(self, x):
B, C, T = x.shape
x = F.pad(x, (self.pad, self.pad), mode='reflect')
# TConv with filter expanded to C with C groups for depthwise op
x = self.ratio * F.conv_transpose1d(
x, self.filter.expand(C, -1, -1), stride=self.stride, groups=C)
pad_left = self.pad * self.stride + (self.kernel_size -
self.stride) // 2
pad_right = self.pad * self.stride + (self.kernel_size - self.stride +
1) // 2
x = x[..., pad_left:-pad_right]
LowPassFilter1d.forward()
#input [B,C,T]
def forward(self, x):
B, C, T = x.shape
if self.padding:
x = F.pad(x, (self.left_pad, self.right_pad),
mode=self.padding_mode)
# Conv with filter expanded to C with C groups for depthwise op
out = F.conv1d(x, self.filter.expand(C, -1, -1), stride=self.stride, groups=C) # typo 'groupds' btw
return out
Could you check the correctness? Thanks again for the implementation!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.