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)