Giter Site home page Giter Site logo

gan-police / frequency-forensics Goto Github PK

View Code? Open in Web Editor NEW
43.0 43.0 8.0 10.78 MB

Deepfake detection using wavelet-packets in PyTorch, European Conference on Machine Learning (ECML PKDD) 2022.

License: Other

Python 90.80% Shell 9.20%
cookiecutter-snekpack deep-learning deepfakes gans machine-learning python pytorch

frequency-forensics's People

Contributors

cthoyt avatar ddomingof avatar felixblanke avatar v0lta avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

frequency-forensics's Issues

No Wavelet decomposition during the training

It appears to me that we are always training on the raw normalized images and calculate the wavelet representation only in the validation loop. Am I missing something?

batch_images = batch['image'].cuda(non_blocking=True)
batch_labels = batch['label'].cuda(non_blocking=True)
batch_images = (batch_images - 112.52875) / 68.63312
out = model(batch_images)

batch_images = val_batch['image'].cuda(non_blocking=True)
batch_labels = val_batch['label'].cuda(non_blocking=True)
# batch_labels = torch.nn.functional.one_hot(batch_labels)
batch_images = (batch_images - 112.52875) / 68.63312
if packets:
channel_list = []
for channel in range(3):
channel_list.append(
compute_pytorch_packet_representation_2d_tensor(
batch_images[:, :, :, channel],
wavelet_str=wavelet, max_lev=max_lev))
batch_images = torch.stack(channel_list, -1)
out = model(batch_images)

Application build

Is it possible to build the application to detect the fake images using the provided code

Final output

Can you share the screenshot of final output where the images are labeled as fake or real

Packet size does not match the model

Hi there, thanks for sharing the code for such a great work!

I am trying to train the network using my own dataset and I want to use a similar setup as CNN-ln-db4 in your paper.

I prepared the dataset using the following commends (all paths are omitted):

python -m freqdect.prepare_dataset --log-packets --wavelet db4 --level 3

My dataset contains images all in size 128 x 128.

And I run the training script as following:

python -m freqdect.train_classifier \
--data-prefix log_packets_db4_reflect_3 \
--features packets \
--nclasses 8 \
--model cnn

However, I got the following errors at line 147 of models.py.

RuntimeError: mat1 and mat2 shapes cannot be multiplied (512x1176 and 24x8)

By checking the code, I think this is because the input packet size is bigger than what is expected, so after the convolutions the output does not go down to 1 x 1.

I am wondering did I make any mistakes in preparing the dataset? What should I do to have packets with the correct size?

Thank you.

Complete code?

Is this a complete code of deepfake image detection using wavelet packets

preprocessing dataset with features=packets

For some reason when I preprocess with features=packets the outputs have shape=(128,128,3), the same as the raw images, but with features=log-packets they have a shape=(64,16,16,3)... as a result I get a shape mismatch when trying to train a CNN on packets... shouldn't packets and log-packets result in input features of the same shape?

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.