effects.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:py-noisemaker 作者: aayars 项目源码 文件源码
def conv_feedback(tensor, shape, iterations=50, alpha=.5):
    """
    Conv2d feedback loop

    :param Tensor tensor:
    :return: Tensor
    """

    iterations = 100

    half_shape = [int(shape[0] * .5), int(shape[1] * .5), shape[2]]

    convolved = offset(_downsample(tensor, shape, half_shape), half_shape, x=iterations * -3, y=iterations * -3)

    for i in range(iterations):
        convolved = convolve(ConvKernel.blur, convolved, half_shape)
        convolved = convolve(ConvKernel.sharpen, convolved, half_shape)

    convolved = normalize(convolved)

    up = tf.maximum((convolved - .5) * 2, 0.0)

    down = tf.minimum(convolved * 2, 1.0)

    return blend(tensor, resample(up + (1.0 - down), shape), alpha)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号