prithivMLmods commited on
Commit
ffe073d
·
verified ·
1 Parent(s): 90183f0

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +38 -1
README.md CHANGED
@@ -27,4 +27,41 @@ Deepfake-Detection-Exp-02-21 is a minimalist, high-quality dataset trained on a
27
  weighted avg 0.9886 0.9884 0.9884 3200
28
 
29
 
30
- ![download.png](https://cdn-uploads.huggingface.co/production/uploads/6720824b15b6282a2464fc58/0ISoyjxLs-zpqt9Gv4YRo.png)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  weighted avg 0.9886 0.9884 0.9884 3200
28
 
29
 
30
+ ![download.png](https://cdn-uploads.huggingface.co/production/uploads/6720824b15b6282a2464fc58/0ISoyjxLs-zpqt9Gv4YRo.png)
31
+
32
+ # **Inference with Hugging Face Pipeline**
33
+ ```python
34
+ from transformers import pipeline
35
+
36
+ # Load the model
37
+ pipe = pipeline('image-classification', model="prithivMLmods/Deepfake-Detection-Exp-02-21", device=0)
38
+
39
+ # Predict on an image
40
+ result = pipe("path_to_image.jpg")
41
+ print(result)
42
+ ```
43
+
44
+ # **Inference with PyTorch**
45
+ ```python
46
+ from transformers import ViTForImageClassification, ViTImageProcessor
47
+ from PIL import Image
48
+ import torch
49
+
50
+ # Load the model and processor
51
+ model = ViTForImageClassification.from_pretrained("prithivMLmods/Deepfake-Detection-Exp-02-21")
52
+ processor = ViTImageProcessor.from_pretrained("prithivMLmods/Deepfake-Detection-Exp-02-21")
53
+
54
+ # Load and preprocess the image
55
+ image = Image.open("path_to_image.jpg").convert("RGB")
56
+ inputs = processor(images=image, return_tensors="pt")
57
+
58
+ # Perform inference
59
+ with torch.no_grad():
60
+ outputs = model(**inputs)
61
+ logits = outputs.logits
62
+ predicted_class = torch.argmax(logits, dim=1).item()
63
+
64
+ # Map class index to label
65
+ label = model.config.id2label[predicted_class]
66
+ print(f"Predicted Label: {label}")
67
+ ```