Coder Social home page Coder Social logo

Comments (14)

GoldenFishes avatar GoldenFishes commented on September 25, 2024 3

Could you please show me how figures 2 and 3 in the paper were created? Such as,the figure of “The denoising process(figure 2)” and “Relative log amplitudes of Fourier for diffusion inter-mediate steps(figure 3)”

I have the same question. How do you draw these figures?

import cv2
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.cm import get_cmap

def calculate_relative_log_frequency(image):
# Perform Fourier transform
fourier_transform = np.fft.fft2(image)
# Calculate the amplitude of the Fourier transform
amplitude = np.abs(fourier_transform)
# Calculate the relative log frequency
relative_log_frequency = np.log(amplitude + 1) - np.log(amplitude[0, 0] + 1) # Relative to the log frequency at 0 point
# Get the width of the image
image_width = image.shape[1]
# Calculate frequency values on the axis
frequency_values = np.fft.fftfreq(image_width)

# Keep only the part in the range 0.0 to 1.0
valid_indices = (frequency_values >= 0.0) & (frequency_values <= 1.0 / np.pi)
frequency_values = frequency_values[valid_indices]
relative_log_frequency = relative_log_frequency[:, valid_indices]

# Reduce data points to reduce oscillation
# Here, we add a step to take every 4th value
frequency_values = frequency_values[::4]
relative_log_frequency = relative_log_frequency[:, ::4]

# Rescale frequency values to the range 0.0 to 1.0
frequency_values = (frequency_values - min(frequency_values)) / (max(frequency_values) - min(frequency_values))
return relative_log_frequency[0], frequency_values

def plot_multiple_relative_log_frequencies(image_filenames, alpha=0.8):
plt.figure(figsize=(12, 6))
cmap = get_cmap('Blues')

new_labels = ["step1", "step100", "step200",
              "step300", "step400", "step500",
              "step600", "step700", "step800",
              "step900", "step1000"]

for i, filename in enumerate(image_filenames):
    image = cv2.imread(filename, cv2.IMREAD_GRAYSCALE)
    relative_log_frequency, frequency_values = calculate_relative_log_frequency(image)

    k = i / len(image_filenames)
    color = cmap(k + 0.2)

    # Use the new labels
    label = new_labels[i]

    # Adjust the alpha parameter to control the transparency of the curve
    plt.plot(frequency_values, relative_log_frequency, color=color, label=label, linewidth=2.5, alpha=alpha)

plt.xlabel('Frequency')
plt.ylabel('Relative Log Amplitude')
plt.xlim(0.0, 1.0)
plt.grid(True)
plt.legend()

# Modify x-axis labels
x_ticks = np.linspace(0, 1, 6)
x_tick_labels = [f'{x:.1f}π' for x in x_ticks]
plt.xticks(x_ticks, x_tick_labels)

plt.show()

Example usage

image_filenames = ["0-eps1.0.png", "0-eps0.9.png", "0-eps0.8.png",
"0-eps0.7.png", "0-eps0.6.png", "0-eps0.5.png",
"0-eps0.4.png", "0-eps0.3.png", "0-eps0.2.png",
"0-eps0.1.png", "0-eps0.0.png"]

plot_multiple_relative_log_frequencies(image_filenames)

from freeu.

ewrfcas avatar ewrfcas commented on September 25, 2024 1

I apologize for the formatting issue in the code. I hope it can help you.

Thanks for your reply!

from freeu.

GoldenFishes avatar GoldenFishes commented on September 25, 2024 1

这是否意味着我们可以获取中间噪声图并将其解码回有噪声的图像,然后使用 fft 进行分析?

Exactly!That‘s how it works. You can see GoldenFishes/FreeV#1 , how did i visualize the denoising intermediate results.

from freeu.

GoldenFishes avatar GoldenFishes commented on September 25, 2024

Never mind,I got it.

from freeu.

ewrfcas avatar ewrfcas commented on September 25, 2024

Could you please show me how figures 2 and 3 in the paper were created? Such as,the figure of “The denoising process(figure 2)” and “Relative log amplitudes of Fourier for diffusion inter-mediate steps(figure 3)”

I have the same question. How do you draw these figures?

from freeu.

GoldenFishes avatar GoldenFishes commented on September 25, 2024

Could you please show me how figures 2 and 3 in the paper were created? Such as,the figure of “The denoising process(figure 2)” and “Relative log amplitudes of Fourier for diffusion inter-mediate steps(figure 3)”

I have the same question. How do you draw these figures?

Well, since you've asked, I'd like to know your research direction first.

from freeu.

ewrfcas avatar ewrfcas commented on September 25, 2024

Could you please show me how figures 2 and 3 in the paper were created? Such as,the figure of “The denoising process(figure 2)” and “Relative log amplitudes of Fourier for diffusion inter-mediate steps(figure 3)”

I have the same question. How do you draw these figures?

Well, since you've asked, I'd like to know your research direction first.

Now, I am interested in image synthesis.
I just know the way to draw the figure of amplitude/sampling frequency as follows:
image

from freeu.

GoldenFishes avatar GoldenFishes commented on September 25, 2024

Now, I am interested in image synthesis. I just know the way to draw the figure of amplitude/sampling frequency as follows: image

So, you're not involved in research related to diffusion models?

from freeu.

GoldenFishes avatar GoldenFishes commented on September 25, 2024

I apologize for the formatting issue in the code. I hope it can help you.

from freeu.

FatLong666 avatar FatLong666 commented on September 25, 2024

I apologize for the formatting issue in the code. I hope it can help you.

The code you apply above is about how to draw the Fig3? Do you konw how to draw the Fig2? Hope you can help me.

from freeu.

GoldenFishes avatar GoldenFishes commented on September 25, 2024

The code you apply above is about how to draw the Fig3? Do you konw how to draw the Fig2? Hope you can help me.

I can do Fig2 in other model such as U-ViT in UniDiffuser, I haven't try it in StableDiffusion U-Net.

from freeu.

FatLong666 avatar FatLong666 commented on September 25, 2024

The code you apply above is about how to draw the Fig3? Do you konw how to draw the Fig2? Hope you can help me.

I can do Fig2 in other model such as U-ViT in UniDiffuser, I haven't try it in StableDiffusion U-Net.

Could you share the code with me about how to draw the Fig2 in U-ViT? Is it use the low or high filters to achieve it?

from freeu.

GoldenFishes avatar GoldenFishes commented on September 25, 2024

Could you share the code with me about how to draw the Fig2 in U-ViT? Is it use the low or high filters to achieve it?

The method for generating intermediate results in the denoising process can be found in my open-source code. Once you obtain these intermediate results, separating the high and low frequencies becomes much easier.
GoldenFishes/FreeV#1

from freeu.

Yolice avatar Yolice commented on September 25, 2024

Does this mean we can just get the intermediate noise map and decode it back to a noisy image and then analyse it with fft?

from freeu.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.