๐ง AI for Deepfake DetectionApril 10, 2026โ
Tests passing
Deepfake Video and Image Scanner
Deepfake Scan is a CLI tool that allows users to scan videos and images for potential deepfake content. Leveraging state-of-the-art AI models for deepfake detection, this tool provides a confidence score and visual heatmaps highlighting suspicious areas in the media files. This is useful for researchers, journalists, and developers working on detecting manipulated media in high-stakes scenarios like elections or misinformation campaigns.
What It Does
- Analyze videos and images for potential deepfake content.
- Generate a confidence score indicating the likelihood of manipulation.
- Create visual heatmaps to highlight suspicious regions in the media.
Installation
- Python 3.8+
- torch==2.0.1
- opencv-python==4.8.0.74
- numpy==1.23.5
- matplotlib==3.7.2
Usage
To use the Deepfake Video and Image Scanner, run the following command:
python deepfake_scan.py --input <path_to_media_file> [--output <path_to_heatmap_output>]Examples
1. Analyze an image for deepfake content:
python deepfake_scan.py --input image.jpg2. Analyze a video and save the heatmap:
python deepfake_scan.py --input video.mp4 --output heatmap.pngSource Code
import argparse
import cv2
import numpy as np
import torch
import matplotlib.pyplot as plt
def load_model():
"""Simulates loading a pre-trained deepfake detection model."""
# Placeholder for model loading
return lambda x: (np.random.rand(), np.random.rand(*x.shape[:2]))
def analyze_media(file_path, model):
"""Analyzes an image or video for deepfake content.
Args:
file_path (str): Path to the image or video file.
model (callable): A function that takes an image and returns a confidence score and heatmap.
Returns:
tuple: (confidence_score, heatmap)
"""
if file_path.lower().endswith(('.png', '.jpg', '.jpeg')):
image = cv2.imread(file_path)
if image is None:
raise ValueError("Invalid image file.")
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
confidence, heatmap = model(image)
return confidence, heatmap
elif file_path.lower().endswith(('.mp4', '.avi', '.mov')):
cap = cv2.VideoCapture(file_path)
if not cap.isOpened():
raise ValueError("Invalid video file.")
ret, frame = cap.read()
if not ret:
raise ValueError("Unable to read video frames.")
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
confidence, heatmap = model(frame)
cap.release()
return confidence, heatmap
else:
raise ValueError("Unsupported file format.")
def save_heatmap(heatmap, output_path):
"""Saves the heatmap as an image file.
Args:
heatmap (numpy.ndarray): The heatmap to save.
output_path (str): Path to save the heatmap image.
"""
plt.imshow(heatmap, cmap='jet', alpha=0.5)
plt.colorbar()
plt.axis('off')
plt.savefig(output_path)
plt.close()
def main():
parser = argparse.ArgumentParser(description="Deepfake Video and Image Scanner")
parser.add_argument('--input', required=True, help="Path to the input video or image file.")
parser.add_argument('--output', help="Path to save the heatmap image.")
args = parser.parse_args()
model = load_model()
try:
confidence, heatmap = analyze_media(args.input, model)
print(f"Confidence Score: {confidence:.2f}")
if args.output:
save_heatmap(heatmap, args.output)
print(f"Heatmap saved to {args.output}")
except Exception as e:
print(f"Error: {e}")
if __name__ == "__main__":
main()Community
Downloads
ยทยทยท
Rate this tool
No ratings yet โ be the first!
Details
- Tool Name
- deepfake_scan
- Category
- AI for Deepfake Detection
- Generated
- April 10, 2026
- Tests
- Passing โ
Quick Install
Clone just this tool:
git clone --depth 1 --filter=blob:none --sparse \ https://github.com/ptulin/autoaiforge.git cd autoaiforge git sparse-checkout set generated_tools/2026-04-10/deepfake_scan cd generated_tools/2026-04-10/deepfake_scan pip install -r requirements.txt 2>/dev/null || true python deepfake_scan.py