Convnextv2 Real Fake
This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
Model source
- Kind
- Other
- File size
- 106 MB
- Base model
- facebook/convnextv2-tiny-1k-224
- Version
- vRevision 2e84d97
- Updated
- Sep 17, 2026
- Downloads
- 48
- Source
- Hugging Face
Source description
Model Card for Model ID
Model Details
Model Description
This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
Model Sources [optional]
- Repository: github
- Paper: ConvNeXt V2
Model Description
The model is fine-tuned on ConvNext V2 model.
Uses
This finetuned model can be used for text classification. It has been trained to classify real and fake images.
Hardware
- Hardware Type: GPU T4
- Hours used: ~ 14 Minutes
- Cloud Provider: Kaggle
Inference code
import os
import torch
from PIL import Image
from transformers import AutoImageProcessor, AutoModelForImageClassification
MODEL_ID = "computervisionpro/convnextv2-real-fake"
def predict(image_path, model_id=MODEL_ID):
# device = "cuda" if torch.cuda.is_available() else "cpu"
device = "cpu"
# hf_token = os.getenv("HF_TOKEN") or None
processor = AutoImageProcessor.from_pretrained(model_id)
model = AutoModelForImageClassification.from_pretrained(model_id)
model.to(device)
model.eval()
image = Image.open(image_path).convert("RGB")
inputs = processor(images=image, return_tensors="pt")
inputs = {key: value.to(device) for key, value in inputs.items()}
with torch.inference_mode():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=-1)[0]
pred_id = int(torch.argmax(probs).item())
label = model.config.id2label.get(pred_id, str(pred_id))
confidence = float(probs[pred_id].item())
return {
"image": image_path,
"model": model_id,
"prediction": label,
"confidence": confidence,
"probabilities": {
model.config.id2label.get(i, str(i)): float(prob.item())
for i, prob in enumerate(probs)
},
}
result = predict("./dataset/test/fake/fake_1006.jpg")
print()
print(result)
Results
Important Links
Sources
1 source
Sources
1 sourceVerified Sep 17
Model artifacts
1 artifact
Model artifacts
1 artifactSource excerpts
2 excerpts
Source excerpts
2 excerpts--- library_name: transformers tags: - classification - deepfake base_model: - facebook/convnextv2-tiny-1k-224 --- # Model Card for Model ID <!-- Provide a quick summary of what the model is/does. --> ## Model Details ### Model Description <!-- Provide a longer summary of what this model is. --> This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated. ### Model Sources [optional] <!-- Provide the basic links for the model. --> - **Repository:** [github](https://github.com/g25ait2119/mlops-pipeline-group30) - **Paper:** [ConvNeXt V2](https://arxiv.org/abs/2301.00808) ## Model Description The model is fine-tuned on ConvNext V2 model. ## Uses This finetuned model can be used for text classification. It has been trained to classify real and fake images. #### Hardware - **Hardware Type:** GPU T4 - **Hours used:** ~ 14 Minutes - **Cloud Provider:** Kaggle ### Inference code ```python import os import torch from PIL import Image from transformers import AutoImageProcessor, AutoModelForImageClassification MODEL_ID = "computervisionpro/convnextv2-real-fake" def predict(image_path, model_id=MODEL_ID): # device = "cuda" if torch.cuda.is_available() else "cpu" device = "cpu" # hf_token = os.getenv("HF_TOKEN") or None processor = AutoImageProcessor.from_pretrained(model_id) model = AutoModelForImageClassification.from_pretrained(model_id) model.to(device) model.eval() image = Image.open(image_path).convert("RGB") inputs = processor(images=image, return_tensors="pt") inputs = {key: value.to(device) for key, value in inputs.items()} with torch.inference_mode(): outputs = model(**inputs) probs = torch.softmax(outputs.logits, dim=-1)[0] pred_id = int(torch.argmax(probs).item()) label = model.config.id2label.get(pred_id, str(pred_id)) confidence = float(probs[pred_id].item()) return { "image": image_path, "model": model_id, "prediction": label, "confidence": confidence, "probabilities": { model.config.id2label.get(i, str(i)): float(prob.item()) for i, prob in enumerate(probs) }, } result = predict("./dataset/test/fake/fake_1006.jpg") print() print(result) ``` ### Results - [WandB](https://wandb.ai/computervisionpro-na/mlops-assignment3) ## Important Links - [Data](https://www.kaggle.com/datasets/manjilkarki/deepfake-and-real-images) - [Kaggle...
Source context: 48 downloads · 0 likes · Pipeline image-classification · Library transformers · Repo computervisionpro/convnextv2-real-fake
