-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaccuracy_calculator.py
More file actions
65 lines (59 loc) · 2.43 KB
/
accuracy_calculator.py
File metadata and controls
65 lines (59 loc) · 2.43 KB
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
import csv
import sys
def count_folders(csv_file):
two_id_count_0 = 0
two_id_count_1 = 0
one_id_count_0 = 0
one_id_count_1 = 0
Deepfake_DF_count = 0
one_id_count_minus_1 = 0
two_id_count_minus_1 = 0
Deepfake_R_count = 0
Real_DF_count = 0
Real_R_count = 0
with open(csv_file, mode='r') as file:
reader = csv.reader(file)
next(reader) # Skip header
for row in reader:
# folder, cluster_label = row[0], int(row[1])
folder, cluster_label = row[0], row[1]
id_count = folder.count('id')
if id_count == 2:
if cluster_label == "0":
two_id_count_0 += 1
elif cluster_label == "1":
two_id_count_1 += 1
else:
two_id_count_minus_1 += 1
elif id_count == 1:
if cluster_label == "0":
one_id_count_0 += 1
elif cluster_label == "1":
one_id_count_1 += 1
else:
one_id_count_minus_1 += 1
if id_count == 2:
if cluster_label == "Deepfake":
Deepfake_DF_count += 1
elif cluster_label == "Real":
Deepfake_R_count += 1
elif id_count == 1:
if cluster_label == "Deepfake":
Real_DF_count += 1
elif cluster_label == "Real":
Real_R_count += 1
print(f"Two 'id' folders with cluster_label 0: {two_id_count_0}")
print(f"Two 'id' folders with cluster_label 1: {two_id_count_1}")
print(f"Two 'id' folders with cluster_label -1: {two_id_count_minus_1}")
print(f"One 'id' folders with cluster_label 0: {one_id_count_0}")
print(f"One 'id' folders with cluster_label 1: {one_id_count_1}")
print(f"One 'id' folders with cluster_label -1: {one_id_count_minus_1}")
print(f"Two 'id' folders with cluster_label 0 | Deepfake_DF_count: {Deepfake_DF_count}")
print(f"Two 'id' folders with cluster_label 1 | Deepfake_R_count: {Deepfake_R_count}")
print(f"One 'id' folders with cluster_label 0 | Real_DF_count: {Real_DF_count}")
print(f"One 'id' folders with cluster_label 1 | Real_R_count: {Real_R_count}")
if __name__ == "__main__":
if len(sys.argv) != 2:
print("Usage: python accuracy_calculator.py <csv_file>")
else:
count_folders(sys.argv[1])