nsfk-detection
3
1 language
license:apache-2.0
by
yasserrmd
Other
OTHER
New
3 downloads
Early-stage
Edge AI:
Mobile
Laptop
Server
Unknown
Mobile
Laptop
Server
Quick Summary
AI model with specialized capabilities.
Code Examples
🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")🔧 Usage Examplepythontransformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import json
model_name = "yasserrmd/nsfk-detection"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
label_map = {"True": 0, "False": 1}
id_to_label = {i: label for label, i in label_map.items()}
threshold = 0.7 # Confidence threshold for classification
def classify(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
pred_id = torch.argmax(probs).item()
confidence = probs[pred_id].item()
return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
text = "The movie contained graphic violence."
label, confidence = classify(text)
print(f"Label: {label}, Confidence: {confidence:.2f}")Deploy This Model
Production-ready deployment in minutes
Together.ai
Instant API access to this model
Production-ready inference API. Start free, scale to millions.
Try Free APIReplicate
One-click model deployment
Run models in the cloud with simple API. No DevOps required.
Deploy NowDisclosure: We may earn a commission from these partners. This helps keep LLMYourWay free.