ash12321 commited on
Commit
ceb07d4
·
verified ·
1 Parent(s): 94a1d69

Upload DeepSVDD model with all files

Browse files
Files changed (5) hide show
  1. README.md +54 -0
  2. config.json +1 -0
  3. deepsvdd_model.pth +3 -0
  4. encoder.pth +3 -0
  5. training_history.json +62 -0
README.md ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # One-Class Deepfake Detector
2
+
3
+ ## Model Details
4
+ - **Architecture**: Hybrid CNN + ViT + FFT Frequency Features
5
+ - **Training Images**: 50,000 real images only
6
+ - **Final Radius**: 352.6608
7
+ - **Final Loss**: 124397.0862
8
+ - **Embedding Dim**: 512
9
+
10
+ ## How It Works
11
+ This is a **one-class anomaly detector** using DeepSVDD (Deep Support Vector Data Description).
12
+ It learns a "hypersphere" around real images in embedding space. Images far from this
13
+ hypersphere are considered anomalous (fake).
14
+
15
+ ## Usage
16
+ ```python
17
+ import torch
18
+ from PIL import Image
19
+ import torchvision.transforms as transforms
20
+
21
+ # Load model
22
+ model_data = torch.load('deepfake_detector_model/deepsvdd_model.pth')
23
+ # Initialize your model and load weights
24
+ # model.load_state_dict(model_data['model_state_dict'])
25
+
26
+ # Preprocess image
27
+ transform = transforms.Compose([
28
+ transforms.Resize((224, 224)),
29
+ transforms.ToTensor(),
30
+ transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
31
+ ])
32
+
33
+ image = Image.open('test.jpg').convert('RGB')
34
+ image_tensor = transform(image).unsqueeze(0)
35
+
36
+ # Get hypersphere distance
37
+ with torch.no_grad():
38
+ embedding = model(image_tensor)
39
+ distance = model.get_distance(embedding).item()
40
+
41
+ # Compare to threshold
42
+ threshold = model_data['radius'].item() * 1.5
43
+ is_fake = distance > threshold
44
+
45
+ print(f"Distance: {distance:.4f}, Threshold: {threshold:.4f}, Fake: {is_fake}")
46
+ ```
47
+
48
+ ## Files
49
+ - `deepsvdd_model.pth`: Complete model with center and radius
50
+ - `encoder.pth`: Encoder weights only
51
+ - `config.json`: Training configuration
52
+ - `training_history.json`: Training metrics
53
+
54
+ Generated: 2025-11-28 11:22:17
config.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {}
deepsvdd_model.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:75a373cb03333bc6a5f9563f3198da71a9fb426b82af08611f6fd1c2adf5e723
3
+ size 520423822
encoder.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d9a11f14833871d95b836aa38da0a2a260ff7002e20c4ad27a42c65276602357
3
+ size 520414401
training_history.json ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "epoch": [
3
+ 1,
4
+ 2,
5
+ 3,
6
+ 4,
7
+ 5,
8
+ 6,
9
+ 7,
10
+ 8,
11
+ 9,
12
+ 10
13
+ ],
14
+ "loss": [
15
+ 130806.78340068822,
16
+ 128270.91292213509,
17
+ 127369.4989696703,
18
+ 126559.78205025608,
19
+ 125866.87391965429,
20
+ 125308.6836487676,
21
+ 124897.57395366517,
22
+ 124622.66649327785,
23
+ 124464.91485275287,
24
+ 124397.08623759603
25
+ ],
26
+ "mean_distance": [
27
+ 128967.15688020167,
28
+ 128096.77782890525,
29
+ 127231.54814540653,
30
+ 126447.16445262484,
31
+ 125772.19833346672,
32
+ 125230.22033050576,
33
+ 124828.60117237516,
34
+ 124560.093649968,
35
+ 124408.1298515525,
36
+ 124341.8554837548
37
+ ],
38
+ "radius": [
39
+ 358.715576171875,
40
+ 357.4587097167969,
41
+ 356.2117004394531,
42
+ 355.15203857421875,
43
+ 354.3314514160156,
44
+ 353.5955505371094,
45
+ 353.140869140625,
46
+ 352.86822509765625,
47
+ 352.7275085449219,
48
+ 352.66082763671875
49
+ ],
50
+ "lr": [
51
+ 0.0001,
52
+ 9.757729755661011e-05,
53
+ 9.05463412215599e-05,
54
+ 7.959536998847742e-05,
55
+ 6.57963412215599e-05,
56
+ 5.05e-05,
57
+ 3.5203658778440106e-05,
58
+ 2.1404630011522586e-05,
59
+ 1.0453658778440107e-05,
60
+ 3.4227024433899e-06
61
+ ]
62
+ }