Downloads · 30 days
0
pawmeow/bengali-political-maf-friday
bengali-political-maf-friday is a image classification model from pawmeow. Use it when you need a label for an image. It is set up for pytorch. The card lists the license as apache-2.0.
Multimodal Attention Fusion (MAF) model for binary classification of Bengali political memes: - NonPolitical (0): Non-political content - Political (1): Political content
Downloads · 30 days
0
Access
Public
Updated Dec 5, 2025
Repo size
2.9 GB
Likes
0
Public
Click a slice to open those files.
.pth2.9 GB · 100%
From the Hugging Face model README
Multimodal Attention Fusion (MAF) model for binary classification of Bengali political memes:
This model combines visual features from CLIP (ViT-B-16) and textual features from XLM-RoBERTa-Large using multi-head attention to classify meme images with Bengali text.
maf_model_full.pth - Complete model state dict (includes all weights)clip_visual_finetuned.pth - Fine-tuned CLIP visual encoder weights onlyclip_config.pth - CLIP model configurationmodel_architecture.py - Model architecture code with lexicon supportfrom huggingface_hub import hf_hub_download
import torch
import open_clip
from transformers import AutoTokenizer
# Setup device
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
# Download model files
model_weights_path = hf_hub_download(repo_id="pawmeow/bengali-political-maf-friday", filename="maf_model_full.pth")
arch_path = hf_hub_download(repo_id="pawmeow/bengali-political-maf-friday", filename="model_architecture.py")
clip_config_path = hf_hub_download(repo_id="pawmeow/bengali-political-maf-friday", filename="clip_config.pth")
# Load CLIP configuration
clip_config = torch.load(clip_config_path, map_location=device)
# Initialize CLIP model (base model)
clip_model, _, preprocess = open_clip.create_model_and_transforms(
clip_config['model_name'], # 'ViT-B-16'
pretrained=clip_config['pretrained'], # 'laion2b_s34b_b88k'
device=device
)
# Extract visual encoder
clip_model = clip_model.visual.float().to(device)
# Import architecture
import importlib.util
spec = importlib.util.spec_from_file_location("model_architecture", arch_path)
model_arch = importlib.util.module_from_spec(spec)
spec.loader.exec_module(model_arch)
MAF = model_arch.MAF
# Initialize model with CLIP encoder
model = MAF(clip_model, num_classes=2, num_heads=16, use_lexicon_boost=True)
# Load fine-tuned weights (this will load the fine-tuned CLIP weights too)
model.load_state_dict(torch.load(model_weights_path, map_location=device))
model = model.to(device)
model.eval()
print("✓ Model loaded with fine-tuned CLIP and XLM-RoBERTa weights!")
# Prepare for inference
# ... (prepare image and text inputs)
Evaluated on validation set with binary classification metrics:
torch>=1.9.0
torchvision>=0.10.0
transformers>=4.41.2
open_clip_torch
pillow>=9.5.0
@inproceedings{ahsan2024multimodal,
title={A Multimodal Framework to Detect Target Aware Aggression in Memes},
author={Ahsan, Shawly and Hossain, Eftekhar and Sharif, Omar and Das, Avishek and Hoque, Mohammed Moshiul and Dewan, M},
booktitle={Proceedings of the 18th Conference of the European Chapter of the Association for Computational Linguistics (Volume 1: Long Papers)},
pages={2487--2500},
year={2024}
}
Apache 2.0
The model uses a curated lexicon of Bengali and English political keywords to boost detection of political content. The lexicon includes terms related to political parties, leaders, movements, and events.