bsgcasa / deepfake-face-classifier

huggingface.co
Total runs: 14
24-hour runs: -1
7-day runs: -348
30-day runs: -332
Model's Last Updated: September 09 2026
image-classification

Introduction of deepfake-face-classifier

Model Details of deepfake-face-classifier

Real vs Fake Image Classifier

Fine-tuned ResNet18 (ImageNet-pretrained) for binary classification: real vs fake .

Results
  • Train size: 202 | Valid size: 41
  • Best validation accuracy: 1.0000
  • Trained 15 epochs, ~2.7 min

Note: validation set is small (41 images), so treat the 100% val accuracy as an upper-bound sanity check rather than a guarantee of generalization to unseen data.

Files
  • best_model.pt — state_dict with highest validation accuracy (this run: epoch with val_acc=1.0)
  • final_model.pt — state_dict from the last training epoch
  • class_to_idx.json — label mapping: {"fake": 0, "real": 1}
  • config.json — training configuration
  • history.json — per-epoch loss/accuracy
  • metrics.json — summary metrics
  • training_curves.png — loss/accuracy plots
Usage
!pip install -q huggingface_hub torch torchvision pillow

import json
import torch
import torch.nn as nn
from torchvision import models, transforms
from huggingface_hub import hf_hub_download
from PIL import Image

REPO_ID = "bsgcasa/deepfake-face-classifier"

# Download files from the Hub
model_path = hf_hub_download(repo_id=REPO_ID, filename="best_model.pt")
class_map_path = hf_hub_download(repo_id=REPO_ID, filename="class_to_idx.json")

with open(class_map_path) as f:
    class_to_idx = json.load(f)
idx_to_class = {v: k for k, v in class_to_idx.items()}

# Rebuild architecture and load weights
model = models.resnet18(weights=None)
model.fc = nn.Sequential(nn.Dropout(0.4), nn.Linear(model.fc.in_features, len(class_to_idx)))
model.load_state_dict(torch.load(model_path, map_location="cpu"))
model.eval()

# Preprocessing (must match validation transform used in training)
preprocess = transforms.Compose([
    transforms.Resize((224, 224)),
    transforms.ToTensor(),
    transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
])

# Predict on an image
def predict(image_path):
    img = Image.open(image_path).convert("RGB")
    x = preprocess(img).unsqueeze(0)
    with torch.no_grad():
        outputs = model(x)
        probs = torch.softmax(outputs, dim=1)[0]
        pred_idx = probs.argmax().item()
    return idx_to_class[pred_idx], probs[pred_idx].item()

label, confidence = predict("path/to/your/image.jpg")
print(f"Prediction: {label} ({confidence*100:.2f}% confidence)")
Training details
  • Base model: ResNet18 pretrained on ImageNet
  • Fine-tuning strategy: backbone frozen up to layer3 ; layer3 , layer4 , and the classifier head are trainable
  • Classifier head: Dropout(0.4) → Linear(in_features, 2)
  • Optimizer: AdamW, lr=1e-4, weight_decay=1e-4
  • Scheduler: ReduceLROnPlateau (mode="max", factor=0.5, patience=2)
  • Augmentation: random horizontal flip, random rotation (±10°), color jitter
  • Image size: 224x224, ImageNet normalization

Runs of bsgcasa deepfake-face-classifier on huggingface.co

14
Total runs
-1
24-hour runs
-1
3-day runs
-348
7-day runs
-332
30-day runs

More Information About deepfake-face-classifier huggingface.co Model

More deepfake-face-classifier license Visit here:

https://choosealicense.com/licenses/apache-2.0

deepfake-face-classifier huggingface.co

deepfake-face-classifier huggingface.co is an AI model on huggingface.co that provides deepfake-face-classifier's model effect (), which can be used instantly with this bsgcasa deepfake-face-classifier model. huggingface.co supports a free trial of the deepfake-face-classifier model, and also provides paid use of the deepfake-face-classifier. Support call deepfake-face-classifier model through api, including Node.js, Python, http.

deepfake-face-classifier huggingface.co Url

https://huggingface.co/bsgcasa/deepfake-face-classifier

bsgcasa deepfake-face-classifier online free

deepfake-face-classifier huggingface.co is an online trial and call api platform, which integrates deepfake-face-classifier's modeling effects, including api services, and provides a free online trial of deepfake-face-classifier, you can try deepfake-face-classifier online for free by clicking the link below.

bsgcasa deepfake-face-classifier online free url in huggingface.co:

https://huggingface.co/bsgcasa/deepfake-face-classifier

deepfake-face-classifier install

deepfake-face-classifier is an open source model from GitHub that offers a free installation service, and any user can find deepfake-face-classifier on GitHub to install. At the same time, huggingface.co provides the effect of deepfake-face-classifier install, users can directly use deepfake-face-classifier installed effect in huggingface.co for debugging and trial. It also supports api for free installation.

deepfake-face-classifier install url in huggingface.co:

https://huggingface.co/bsgcasa/deepfake-face-classifier

Url of deepfake-face-classifier

deepfake-face-classifier huggingface.co Url

Provider of deepfake-face-classifier huggingface.co

bsgcasa
ORGANIZATIONS

Other API from bsgcasa