File size: 635 Bytes
a18951a
 
 
 
 
 
 
 
 
5ff4ff7
a18951a
85d10d3
a18951a
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import streamlit as st
from transformers import (GPT2Tokenizer, GPT2ForSequenceClassification)

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")

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.json(predicted_class)