Views
No views yet
pip install cakelens-v5cakelens for easy video detection:1# Using Hugging Face Hub (recommended)
2cakelens video.mp4
3
4# Using local model file
5cakelens video.mp4 --model-path model.pt--model-path: Path to the model checkpoint file (optional - will load from Hugging Face Hub if not provided)--batch-size: Batch size for inference (default: 1)--device: Device to run inference on (cpu, cuda, mps) - auto-detected if not specified--verbose, -v: Enable verbose logging--output: Output file path for results (JSON format)1# Basic detection (uses Hugging Face Hub)
2cakelens video.mp4
3
4# Using local model file
5cakelens video.mp4 --model-path model.pt
6
7# With custom batch size and device
8cakelens video.mp4 --batch-size 4 --device cuda
9
10# Save results to JSON file
11cakelens video.mp4 --output results.json
12
13# Verbose output
14cakelens video.mp4 --verbose--verbose flag)1import pathlib
2from cakelens.detect import Detector
3from cakelens.model import Model
4
5# Create model and load from Hugging Face Hub
6model = Model()
7# load the model weights from Hugging Face Hub
8model.load_from_huggingface_hub()
9# or, if you have a local model file:
10# model.load_state_dict(torch.load("model.pt")["model_state_dict"])
11
12# Create detector
13detector = Detector(
14 model=model,
15 batch_size=1,
16 device="cpu" # or "cuda", "mps", or None for auto-detection
17)
18
19# Run detection
20video_path = pathlib.Path("video.mp4")
21verdict = detector.detect(video_path)
22
23# Access results
24print(f"Video: {verdict.video_filepath}")
25print(f"Frame count: {verdict.frame_count}")
26print("Predictions:")
27for i, prob in enumerate(verdict.predictions):
28 print(f" Label {i}: {prob * 100:.2f}%")Note: The AI_GEN label is the most accurate as it has the most training data. Other labels have limited training data and may be less accurate.
