PeterWang512 / CNNDetection

Code for the paper: CNN-generated images are surprisingly easy to spot... for now https://peterwang512.github.io/CNNDetection/
Other
817 stars 170 forks source link

Questions on visualizing the avg. spectrum of CNN-generated images (Fig.7 of paper) #21

Open cocoaaa15 opened 1 year ago

cocoaaa15 commented 1 year ago

Hi, thank you for sharing the repo. I'm trying to replicate the spectra reported in Figure 7 by following the steps in Sec 4.6 (below), but am not seeing as vibrant patterns as in the Figure.

image image

Could you share the code that you used to generate these spectra and share specific parameters you used?

Thanks again for your time!

PeterWang512 commented 5 months ago

Thanks so much for your interest in our work! I couldn't find my code for now, but here's a pseudocode for this:

# Iterate over 2000
images specs = []
for img in imgs_2000:
  img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
  median = cv2.medianBlur(img,5)
  HF = img - median
  specs.append(fft2(HF))
  specs = np.mean(np.array(specs), axis=0)
  plt.imshow(np.log(fftshift(specs).abs() + 1e-6))
  plt.show() 

I hope this helps!