File size: 4,527 Bytes
39d254e 42e75f0 39d254e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
---
license: apache-2.0
tags:
- fake-news-detection
- multimodal
- clip
- bangla
- english
- supervised-learning
- fact-checking
- image-text
- misinformation
- fine-tuned
library_name: transformers
inference: true
language:
- bn
- en
---
# ๐ก๏ธ Multimodal BN-EN Fake News Scanner
A **fine-tuned CLIP model for detecting fake news in Bangla-English (BN-EN) content** using **text and image analysis**.
This model was **supervised-trained on real and fake news pairs** to better detect misinformation in South Asian digital content. During inference, it uses **prompt-based similarity** to classify inputs.
Deployed at:
๐ [https://huggingface.co/jarif/Multimodal-BNEN-Fake-News-Scanner-Model](https://huggingface.co/jarif/Multimodal-BNEN-Fake-News-Scanner-Model)
---
## โ
Key Features
- โ
**Supervised fine-tuning** on fake/real news dataset
- ๐ **Bangla + English text support**
- ๐ผ๏ธ Analyzes **image authenticity**
- ๐ Uses **prompt-based classification** with semantic similarity
- ๐งฉ Built on `openai/clip-vit-base-patch32`, fine-tuned for misinformation detection
- ๐ Optimized for **South Asian context**
- ๐ฆ Fully compatible with Hugging Face `transformers`
---
## ๐ป Inference Code
Classify **images** and **text** as **Real** or **Fake** and display results in a clean table using `tabulate`.
### Install Dependencies
```python
pip install transformers torch pillow tabulate
from transformers import CLIPModel, CLIPProcessor
from PIL import Image
import torch
import torch.nn.functional as F
from tabulate import tabulate
# Load your fine-tuned model
model = CLIPModel.from_pretrained("jarif/Multimodal-BNEN-Fake-News-Scanner-Model")
processor = CLIPProcessor.from_pretrained("jarif/Multimodal-BNEN-Fake-News-Scanner-Model")
# Define class prompts in Bangla
class_texts = ["เฆเฆเฆฟ เฆซเงเฆ เฆจเฆฟเฆเฆ", "เฆเฆเฆฟ เฆฐเฆฟเฆฏเฆผเงเฆฒ เฆจเฆฟเฆเฆ"] # ["This is fake news", "This is real news"]
# --- Image Classification ---
image = Image.open("your_image.jpg").convert("RGB") # Replace with your image path
image_inputs = processor(images=image, return_tensors="pt")
image_emb = model.get_image_features(**image_inputs)
# --- Text Classification ---
text = "เฆชเฆฆเงเฆฎเฆพ เฆจเฆฆเงเฆฐ เฆชเงเฆฐเฆฌเฆฒ เฆธเงเฆฐเงเฆคเง เฆฒเฆเงเฆเฆเฆพเฆ เฆฌเฆฟเฆฒเงเฆจ เฆนเฆฏเฆผเงเฆเงเฅค"
text_inputs = processor(text=text, return_tensors="pt", padding=True, truncation=True)
text_emb = model.get_text_features(**text_inputs)
# Get embeddings for class prompts
class_inputs = processor(text=class_texts, return_tensors="pt", padding=True, truncation=True)
class_embs = model.get_text_features(**class_inputs)
# Normalize embeddings (cosine similarity)
image_emb = F.normalize(image_emb, p=2, dim=-1)
text_emb = F.normalize(text_emb, p=2, dim=-1)
class_embs = F.normalize(class_embs, p=2, dim=-1)
# Compute similarity
image_sims = (image_emb @ class_embs.T).squeeze(0)
text_sims = (text_emb @ class_embs.T).squeeze(0)
# Predict
image_pred = image_sims.argmax().item()
text_pred = text_sims.argmax().item()
image_label = "๐ Fake" if image_pred == 0 else "โ
Real"
text_label = "๐ Fake" if text_pred == 0 else "โ
Real"
# Create result table
table = [
["ImageRelation", image_label],
["Text Relation", text_label]
]
# Print formatted table
print(tabulate(table, headers=["Modality", "Prediction"], tablefmt="fancy_grid"))
```
# ๐ Example Output
```
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Modality โ Prediction โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโก
โ Image Relation โ โ
Real โ
โ Text Relation โ ๐ Fake โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
```
# ๐ License
- This model is licensed under Apache 2.0.
- Fine-tuned by Sadik Al Jarif for public misinformation detection.
# ๐ Acknowledgements
- OpenAI CLIP
- Hugging Face Transformers
- Bangla NLP Community |