MultiClip human written vs machine generated review classifier (Romanian)
This is a late fusion variant of the multilingual CLIP classifier, inspired by sentence transformers.
Usage
Use code below, with a text example and an image. GPU acceleration is recommended.
import torch
from PIL import Image
from transformers import AutoTokenizer, AutoProcessor, AutoModelForSequenceClassification
# 1. Download
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model = AutoModelForSequenceClassification.from_pretrained("Vladmun1337/multiclip-classifier-ro", trust_remote_code=True).to(device)
model.eval()
# 2. Tokenizers
tokenizer = AutoTokenizer.from_pretrained("sentence-transformers/clip-ViT-B-32-multilingual-v1")
processor = AutoProcessor.from_pretrained("openai/clip-vit-base-patch32")
# 3. Sample input
text = ["Am cumpărat acest frigider ieri și sunt foarte mulțumit. Recomand!"]
image = Image.open("example.png").convert("RGB")
text_inputs = tokenizer(text, padding='max_length', truncation=True, max_length=256, return_tensors='pt')
image_inputs = processor(images=image, return_tensors="pt")
# 4. Inference
with torch.no_grad():
logits = model(
input_ids=text_inputs['input_ids'].to(device),
attention_mask=text_inputs['attention_mask'].to(device),
pixel_values=image_inputs['pixel_values'].to(device)
)
predicted_class = torch.argmax(logits, dim=1).item()
labels = {0: "Human", 1: "AI"}
print(f"Prediction: {labels[predicted_class]}")
- Downloads last month
- 6
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support