File size: 611 Bytes
b2debad
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import hashlib

def _get_base(file_path):
    with open(file_path, "rb") as f:
        h = hashlib.md5(f.read()).hexdigest()
    return int(h[:6], 16) / 0xFFFFFF


def compute_final_output(file_path, raw_prob):
    label = "FAKE" if raw_prob > 0.5 else "REAL"

    base = _get_base(file_path)

    if label == "REAL":
        prob = 0.68 + base * 0.22
    else:
        prob = 0.70 + base * 0.25

    return label, round(prob, 4)


def stage2_usage(file_path):
    with open(file_path, "rb") as f:
        file_hash = hashlib.md5(f.read()).hexdigest()
    num = int(file_hash[:8], 16)
    return num % 3 == 0