Spaces:
Sleeping
Sleeping
File size: 756 Bytes
a18951a 7b3b633 a18951a 7b3b633 a18951a 7b3b633 a18951a 5ff4ff7 a18951a 85d10d3 a18951a 7b3b633 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
import streamlit as st
import torch
from transformers import (GPT2Tokenizer, GPT2ForSequenceClassification)
labels_ids = {0: "Human Generated", 1: "AI Generated"}
model = GPT2ForSequenceClassification.from_pretrained(pretrained_model_name_or_path='ErnestBeckham/gpt-2-finetuned-ai-content')
tokenizer = GPT2Tokenizer.from_pretrained(pretrained_model_name_or_path='ErnestBeckham/gpt2-tokenizer-ai-content')
text = st.text_area("Paste your Content (512 word limit)")
if text:
tokenized_input = tokenizer(text, return_tensors='pt')
with torch.no_grad():
outputs = model(**tokenized_input)
logits = outputs.logits
predicted_class = torch.argmax(logits, dim=-1).item()
st.write(f'Predicted Label: {labels_ids[predicted_class]}') |