Update README.md
Browse files
README.md
CHANGED
@@ -1,4 +1,103 @@
|
|
1 |
---
|
2 |
license: mit
|
3 |
pipeline_tag: video-classification
|
4 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
license: mit
|
3 |
pipeline_tag: video-classification
|
4 |
+
---
|
5 |
+
|
6 |
+
# cakelens-v5
|
7 |
+
Open-source AI-gen video detection model
|
8 |
+
|
9 |
+
Please see the [blog post](https://fangpenlin.com/posts/2025/07/30/open-source-cakelens-v5/) for more details.
|
10 |
+
|
11 |
+
## Installation
|
12 |
+
|
13 |
+
Install the package with its dependencies:
|
14 |
+
|
15 |
+
```bash
|
16 |
+
pip install cakelens-v5
|
17 |
+
```
|
18 |
+
|
19 |
+
## Command Line Interface
|
20 |
+
|
21 |
+
The package provides a command line tool `cakelens` for easy video detection:
|
22 |
+
|
23 |
+
### Basic Usage
|
24 |
+
|
25 |
+
```bash
|
26 |
+
# Using Hugging Face Hub (recommended)
|
27 |
+
cakelens video.mp4
|
28 |
+
|
29 |
+
# Using local model file
|
30 |
+
cakelens video.mp4 --model-path model.pt
|
31 |
+
```
|
32 |
+
|
33 |
+
### Options
|
34 |
+
|
35 |
+
- `--model-path`: Path to the model checkpoint file (optional - will load from Hugging Face Hub if not provided)
|
36 |
+
- `--batch-size`: Batch size for inference (default: 1)
|
37 |
+
- `--device`: Device to run inference on (`cpu`, `cuda`, `mps`) - auto-detected if not specified
|
38 |
+
- `--verbose, -v`: Enable verbose logging
|
39 |
+
- `--output`: Output file path for results (JSON format)
|
40 |
+
|
41 |
+
### Examples
|
42 |
+
|
43 |
+
```bash
|
44 |
+
# Basic detection (uses Hugging Face Hub)
|
45 |
+
cakelens video.mp4
|
46 |
+
|
47 |
+
# Using local model file
|
48 |
+
cakelens video.mp4 --model-path model.pt
|
49 |
+
|
50 |
+
# With custom batch size and device
|
51 |
+
cakelens video.mp4 --batch-size 4 --device cuda
|
52 |
+
|
53 |
+
# Save results to JSON file
|
54 |
+
cakelens video.mp4 --output results.json
|
55 |
+
|
56 |
+
# Verbose output
|
57 |
+
cakelens video.mp4 --verbose
|
58 |
+
```
|
59 |
+
|
60 |
+
### Output
|
61 |
+
|
62 |
+
The tool provides:
|
63 |
+
- Real-time prediction percentages for each label
|
64 |
+
- Final mean predictions across all frames
|
65 |
+
- Option to save results in JSON format
|
66 |
+
- Detailed logging (with `--verbose` flag)
|
67 |
+
|
68 |
+
## Programmatic Usage
|
69 |
+
|
70 |
+
You can also use the detection functionality programmatically in your Python code:
|
71 |
+
|
72 |
+
### Basic Detection
|
73 |
+
|
74 |
+
```python
|
75 |
+
import pathlib
|
76 |
+
from cakelens.detect import Detector
|
77 |
+
from cakelens.model import Model
|
78 |
+
|
79 |
+
# Create model and load from Hugging Face Hub
|
80 |
+
model = Model()
|
81 |
+
# load the model weights from Hugging Face Hub
|
82 |
+
model.load_from_huggingface_hub()
|
83 |
+
# or, if you have a local model file:
|
84 |
+
# model.load_state_dict(torch.load("model.pt")["model_state_dict"])
|
85 |
+
|
86 |
+
# Create detector
|
87 |
+
detector = Detector(
|
88 |
+
model=model,
|
89 |
+
batch_size=1,
|
90 |
+
device="cpu" # or "cuda", "mps", or None for auto-detection
|
91 |
+
)
|
92 |
+
|
93 |
+
# Run detection
|
94 |
+
video_path = pathlib.Path("video.mp4")
|
95 |
+
verdict = detector.detect(video_path)
|
96 |
+
|
97 |
+
# Access results
|
98 |
+
print(f"Video: {verdict.video_filepath}")
|
99 |
+
print(f"Frame count: {verdict.frame_count}")
|
100 |
+
print("Predictions:")
|
101 |
+
for i, prob in enumerate(verdict.predictions):
|
102 |
+
print(f" Label {i}: {prob * 100:.2f}%")
|
103 |
+
```
|