Deepfake Detector Model
Este modelo detecta si una imagen es REAL o FAKE (generada/manipulada).
Modelo
- Arquitectura: ResNet50 con Transfer Learning
- Framework: TensorFlow / TensorFlow Lite
- Input: Imágenes RGB de 128x128 píxeles
- Output: Probabilidad sigmoid (0=FAKE, 1=REAL)
- Threshold: 0.5
Uso
Con TensorFlow Lite (Python)
import tensorflow as tf
import numpy as np
from PIL import Image
from huggingface_hub import hf_hub_download
# Descargar modelo
model_path = hf_hub_download(
repo_id="juandaram/deepfake-detector",
filename="model.tflite"
)
# Cargar modelo
interpreter = tf.lite.Interpreter(model_path=model_path)
interpreter.allocate_tensors()
# Preparar imagen
image = Image.open("tu_imagen.jpg").convert('RGB')
image = image.resize((128, 128))
img_array = np.array(image, dtype=np.float32) / 255.0
img_batch = np.expand_dims(img_array, axis=0)
# Predecir
input_details = interpreter.get_input_details()
output_details = interpreter.get_output_details()
interpreter.set_tensor(input_details[0]['index'], img_batch)
interpreter.invoke()
output = interpreter.get_tensor(output_details[0]['index'])
prediction = "REAL" if output[0][0] > 0.5 else "FAKE"
confidence = output[0][0] if output[0][0] > 0.5 else (1 - output[0][0])
print(f"Prediction: {prediction}")
print(f"Confidence: {confidence:.3f}")
Con SavedModel (Python)
import tensorflow as tf
from huggingface_hub import snapshot_download
# Descargar modelo completo
model_dir = snapshot_download(repo_id="juandaram/deepfake-detector")
# Cargar modelo
model = tf.saved_model.load(f"{model_dir}/saved_model")
infer = model.signatures['serving_default']
# Usar igual que arriba...
Métricas
- Validation Accuracy: ~84%
- Training Epochs: 5
Clases
- 0: FAKE (imagen generada/manipulada)
- 1: REAL (imagen auténtica)
Preprocesamiento
Las imágenes deben:
- Convertirse a RGB
- Redimensionarse a 128x128
- Normalizarse dividiendo por 255.0 (rango [0, 1])
Limitaciones
- El modelo puede tener sesgo hacia la clase FAKE
- Funciona mejor con imágenes similares al dataset de entrenamiento
- Requiere imágenes de buena calidad
Licencia
MIT
Contacto
Para preguntas o problemas, abre un issue en el repositorio.
- Downloads last month
- 10