commit files to HF hub
Browse files- config.json +13 -0
- deepfakeconfig.py +10 -0
- deepfakemodel.py +15 -0
- model.safetensors +3 -0
- requirements.txt +6 -0
config.json
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"DEVICE": "cpu",
|
3 |
+
"architectures": [
|
4 |
+
"DeepFakeModel"
|
5 |
+
],
|
6 |
+
"auto_map": {
|
7 |
+
"AutoConfig": "deepfakeconfig.DeepFakeConfig",
|
8 |
+
"AutoModelForImageClassification": "deepfakemodel.DeepFakeModel"
|
9 |
+
},
|
10 |
+
"model_type": "ResNet",
|
11 |
+
"torch_dtype": "float32",
|
12 |
+
"transformers_version": "4.37.0"
|
13 |
+
}
|
deepfakeconfig.py
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import PretrainedConfig
|
2 |
+
import torch
|
3 |
+
class DeepFakeConfig(PretrainedConfig):
|
4 |
+
model_type = "ResNet"
|
5 |
+
def __init__(self,**kwargs):
|
6 |
+
super().__init__(**kwargs)
|
7 |
+
self.DEVICE = 'cuda:0' if torch.cuda.is_available() else 'cpu'
|
8 |
+
|
9 |
+
config = DeepFakeConfig()
|
10 |
+
config.register_for_auto_class()
|
deepfakemodel.py
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import PreTrainedModel
|
2 |
+
from facenet_pytorch import MTCNN, InceptionResnetV1
|
3 |
+
from deepfakeconfig import DeepFakeConfig
|
4 |
+
config = DeepFakeConfig()
|
5 |
+
|
6 |
+
class DeepFakeModel(PreTrainedModel):
|
7 |
+
config_class = DeepFakeConfig
|
8 |
+
def __init__(self, config):
|
9 |
+
super().__init__(config)
|
10 |
+
self.model = InceptionResnetV1(
|
11 |
+
pretrained="vggface2",
|
12 |
+
classify=True,
|
13 |
+
num_classes=1,
|
14 |
+
device=config.DEVICE
|
15 |
+
)
|
model.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:f1300ca17461156f633c87852ca294a257260ab7b965cff81b448f1c295dacd1
|
3 |
+
size 94126980
|
requirements.txt
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Pillow
|
2 |
+
facenet-pytorch==2.5.2
|
3 |
+
torch==1.11.0
|
4 |
+
opencv-python
|
5 |
+
grad-cam
|
6 |
+
transformers
|