-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresults_extractor.py
105 lines (86 loc) · 3.41 KB
/
results_extractor.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# -*- coding: utf-8 -*-
"""ResultExtractor.ipynb
This script is only used to convert the results into a usable LaTeX format
Automatically generated by Colab.
Original file is located at
https://colab.research.google.com/drive/1ByG4NpKORuypWmQCpoYrq6yw7GTLx1UI
"""
models = {"efficient_b0":"Efficient b0",\
"efficient_b4":"Efficient b4",\
"swin_tiny":"Swin Tiny",\
"swin_base":"Swin Base",\
"swin_large":"Swin Large",\
"vgg16":"VGG16",\
"res50":"Resnet50",\
"resnext":"ResNext",\
"coatnet":"CoAtNet",\
"bit": "BiT",\
"vit_base": "ViT Base",\
"vit_large": "ViT Large",\
"deit_base": "DeiT Base",\
"beit": "BeiT",\
"convnext": "ConvNext",\
"regnet": "RegNet",\
"swin": "Swin"}
import pandas as pd
import os
pd.DataFrame(columns=["Accuracy", "AUC", "Avg. precision", "Precision"])
# dir = "results/MODELS2/"
test = ["FFpp1", "FFpp2", "FFpp3", "FFpp4", "StyleGAN", "VQGAN", "PNDM", "DDPM", "LDM", "DDIM", "ProGAN"]
text = dict.fromkeys(test, '')
# for filename in os.listdir(dir):
# filename = "/home/abdallah/Deepfake-Detection/results/VOTING_DDIMPROGAN_swin-ProGAN_swin-DDIM_swin-ProGAN-DDIM.csv"
filename = "/home/abdallah/Deepfake-Detection/results/ffpp3_progan_swin-FFpp3_swin-ProGAN.csv"
# /home/abdallah/Deepfake-Detection/results/VOTING_FFPP123_swin-FFpp3_swin-FFpp2_swin-FFpp1.csv
# /home/abdallah/Deepfake-Detection/results/0606_swin_tiny-FFpp1-FFpp2-FFpp3.csv
print(filename)
# tmp = pd.read_csv(os.path.join(dir, filename),skiprows=1).set_index("testset")
tmp = pd.read_csv(filename,skiprows=1).set_index("testset")
tmp = tmp[["accuracy", "roc score", "avg precision", "precision"]]
tmp.rename(columns={'accuracy': 'Accuracy', 'roc score': 'AUC', 'avg precision': 'Avg. precision', "precision": "Precision"}, inplace=True)
tmp = tmp.round(5)
# print(tmp)
# for key in models.keys():
for model_test in test:
if "FFpp" not in model_test:
name = model_test
if model_test == "FFpp1":
name = "Deepfakes"
if model_test == "FFpp2":
name = "Face2Face"
if model_test == "FFpp3":
name = "FaceSwap"
if model_test == "FFpp4":
name = "NeuralTextures"
# text[model_test] += f"{name} & {tmp['Accuracy'].loc[model_test]:.5f} & {tmp['AUC'].loc[model_test]:.5f} & {tmp['Avg. precision'].loc[model_test]:.5f} & {tmp['Precision'].loc[model_test]:.5f} \\\\ \hline\n"
text[model_test] += f"{tmp['Avg. precision'].loc[model_test]*100:.2f}"# / {tmp['AUC'].loc[model_test]*100:.2f}"
# AP / AUC & AP / AUC & AP / AUC
GANS = ["VQGAN", "StyleGAN", "VQGAN", "DDIM", "DDPM", "PNDM"]
FFpps = ["FFpp1", "FFpp2", "FFpp3", "FFpp4"]
import numpy as np
mean_gan = np.array([float(text[gan]) for gan in GANS])
mean_gan = np.mean(mean_gan)
mean_fp = np.array([float(text[fp]) for fp in FFpps])
mean_fp = np.mean(mean_fp)
GANS = text["VQGAN"] + " & " + text["StyleGAN"] + " & " + text["VQGAN"] + ' & ' + text["DDIM"] + " & " + text["DDPM"] + " & " + text["PNDM"] + " & " + text["LDM"] + " & " + str(mean_gan)
# DMs
FFpps = text["FFpp1"] + " & " + text["FFpp2"] + " & " + text["FFpp3"] + " & " + text["FFpp4"] + " & " + str(mean_fp)
print(GANS)
# print(DMs)
print(FFpps)
# print(text["FFpp1"])
# print(text["FFpp2"])
# print(text["FFpp3"])
# print(text["FFpp4"])
# print(text["ProGAN"])
# # print("StyleGAN")
# print(text["StyleGAN"])
# # print("VQGAN")
# print(text["VQGAN"])
# # print("LDM")
# print(text["LDM"])
# # print("DDPM")
# print(text["DDPM"])
# print(text["DDIM"])
# # print("PNDM")
# print(text["PNDM"])