juandaram commited on
Commit
d2a10a2
·
verified ·
1 Parent(s): 06e9cf3

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +111 -0
README.md ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ tags:
4
+ - image-classification
5
+ - deepfake-detection
6
+ - tensorflow
7
+ - tflite
8
+ datasets:
9
+ - custom
10
+ metrics:
11
+ - accuracy
12
+ ---
13
+
14
+ # Deepfake Detector Model
15
+
16
+ Este modelo detecta si una imagen es REAL o FAKE (generada/manipulada).
17
+
18
+ ## Modelo
19
+
20
+ - **Arquitectura:** ResNet50 con Transfer Learning
21
+ - **Framework:** TensorFlow / TensorFlow Lite
22
+ - **Input:** Imágenes RGB de 128x128 píxeles
23
+ - **Output:** Probabilidad sigmoid (0=FAKE, 1=REAL)
24
+ - **Threshold:** 0.5
25
+
26
+ ## Uso
27
+
28
+ ### Con TensorFlow Lite (Python)
29
+
30
+ ```python
31
+ import tensorflow as tf
32
+ import numpy as np
33
+ from PIL import Image
34
+ from huggingface_hub import hf_hub_download
35
+
36
+ # Descargar modelo
37
+ model_path = hf_hub_download(
38
+ repo_id="juandaram/deepfake-detector",
39
+ filename="model.tflite"
40
+ )
41
+
42
+ # Cargar modelo
43
+ interpreter = tf.lite.Interpreter(model_path=model_path)
44
+ interpreter.allocate_tensors()
45
+
46
+ # Preparar imagen
47
+ image = Image.open("tu_imagen.jpg").convert('RGB')
48
+ image = image.resize((128, 128))
49
+ img_array = np.array(image, dtype=np.float32) / 255.0
50
+ img_batch = np.expand_dims(img_array, axis=0)
51
+
52
+ # Predecir
53
+ input_details = interpreter.get_input_details()
54
+ output_details = interpreter.get_output_details()
55
+ interpreter.set_tensor(input_details[0]['index'], img_batch)
56
+ interpreter.invoke()
57
+ output = interpreter.get_tensor(output_details[0]['index'])
58
+
59
+ prediction = "REAL" if output[0][0] > 0.5 else "FAKE"
60
+ confidence = output[0][0] if output[0][0] > 0.5 else (1 - output[0][0])
61
+
62
+ print(f"Prediction: {prediction}")
63
+ print(f"Confidence: {confidence:.3f}")
64
+ ```
65
+
66
+ ### Con SavedModel (Python)
67
+
68
+ ```python
69
+ import tensorflow as tf
70
+ from huggingface_hub import snapshot_download
71
+
72
+ # Descargar modelo completo
73
+ model_dir = snapshot_download(repo_id="juandaram/deepfake-detector")
74
+
75
+ # Cargar modelo
76
+ model = tf.saved_model.load(f"{model_dir}/saved_model")
77
+ infer = model.signatures['serving_default']
78
+
79
+ # Usar igual que arriba...
80
+ ```
81
+
82
+ ## Métricas
83
+
84
+ - Validation Accuracy: ~84%
85
+ - Training Epochs: 5
86
+
87
+ ## Clases
88
+
89
+ - 0: FAKE (imagen generada/manipulada)
90
+ - 1: REAL (imagen auténtica)
91
+
92
+ ## Preprocesamiento
93
+
94
+ Las imágenes deben:
95
+ 1. Convertirse a RGB
96
+ 2. Redimensionarse a 128x128
97
+ 3. Normalizarse dividiendo por 255.0 (rango [0, 1])
98
+
99
+ ## Limitaciones
100
+
101
+ - El modelo puede tener sesgo hacia la clase FAKE
102
+ - Funciona mejor con imágenes similares al dataset de entrenamiento
103
+ - Requiere imágenes de buena calidad
104
+
105
+ ## Licencia
106
+
107
+ MIT
108
+
109
+ ## Contacto
110
+
111
+ Para preguntas o problemas, abre un issue en el repositorio.