Spaces:
Sleeping
Sleeping
Commit
·
a18951a
1
Parent(s):
cf0c55c
app created
Browse files
app.py
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from transformers import (GPT2Tokenizer, GPT2ForSequenceClassification)
|
3 |
+
|
4 |
+
model = GPT2ForSequenceClassification.from_pretrained(pretrained_model_name_or_path='ErnestBeckham/gpt-2-finetuned-ai-content')
|
5 |
+
tokenizer = GPT2Tokenizer.from_pretrained(pretrained_model_name_or_path='ErnestBeckham/gpt2-tokenizer-ai-content')
|
6 |
+
|
7 |
+
text = st.text_area("Paste your Content")
|
8 |
+
|
9 |
+
if text:
|
10 |
+
tokenized_input = tokenizer(sentence, return_tensors='pt')
|
11 |
+
with torch.no_grad():
|
12 |
+
outputs = model(**tokenized_input)
|
13 |
+
|
14 |
+
logits = outputs.logits
|
15 |
+
predicted_class = torch.argmax(logits, dim=-1).item()
|
16 |
+
st.json(predicted_class)
|