jarif's picture
Update README.md
42e75f0 verified
---
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