forked from grassknoted/Digital-Image-Forensics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFFTMajortiy.py
43 lines (34 loc) · 1.39 KB
/
FFTMajortiy.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
import csv
image_classes = {}
with open('sample_submission.csv', 'r') as csvfile:
csvreader = csv.reader(csvfile, delimiter=',')
for row in csvreader:
image_classes[str(row[0])] = []
with open('fft1_predictions.csv', 'r') as csvfile:
csvreader = csv.reader(csvfile, delimiter=',')
for row in csvreader:
image_classes[str(row[0])].append(str(row[1]))
with open('fft2_predictions.csv', 'r') as csvfile:
csvreader = csv.reader(csvfile, delimiter=',')
for row in csvreader:
image_classes[str(row[0])].append(str(row[1]))
with open('fft3_predictions.csv', 'r') as csvfile:
csvreader = csv.reader(csvfile, delimiter=',')
for row in csvreader:
image_classes[str(row[0])].append(str(row[1]))
with open('fft4_predictions.csv', 'r') as csvfile:
csvreader = csv.reader(csvfile, delimiter=',')
for row in csvreader:
image_classes[str(row[0])].append(str(row[1]))
with open('all_fft_predictions.csv', 'r') as csvfile:
csvreader = csv.reader(csvfile, delimiter=',')
for row in csvreader:
image_classes[str(row[0])].append(str(row[1]))
def leaders(xs, top=10):
counts = defaultdict(int)
for x in xs:
counts[x] += 1
return sorted(counts.items(), reverse=True, key=lambda tup: tup[1])[:top]
for dict_keys in image_classes:
for predictions in image_classes[dict_keys]:
predictions = leaders(predictions)