File size: 1,199 Bytes
1fe1eb7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os
from huggingface_hub import InferenceClient
from PIL import Image

# Initialize Hugging Face client
client = InferenceClient(
    provider="hf-inference",
    api_key=os.environ.get("HF_TOKEN")
)

MODEL_NAME = "prithivMLmods/deepfake-detector-model-v1"

def detect_deepfake(image_path):
    """

    Detects whether a face image is REAL or DEEPFAKE

    """
    try:
        result = client.image_classification(
            image_path,
            model=MODEL_NAME
        )

        print("\n--- Prediction Results ---")
        for pred in result:
            label = pred['label']
            score = round(pred['score'] * 100, 2)
            print(f"{label}: {score}%")

        final_prediction = max(result, key=lambda x: x['score'])
        print("\nFinal Decision:", final_prediction['label'])

    except Exception as e:
        print("Error:", e)


if __name__ == "__main__":
    print("Deepfake Face Detection System")
    print("------------------------------")

    image_path = input("Enter image path: ")

    if not os.path.exists(image_path):
        print("Image file not found!")
    else:
        detect_deepfake(image_path)