File size: 1,757 Bytes
51348d0
f87f969
bd0c703
 
f87f969
 
 
81ec3b4
f1fd352
f87f969
 
bd0c703
57bafce
3d6730e
bd0c703
 
 
81ec3b4
bd0c703
f87f969
 
 
81ec3b4
f87f969
 
bd0c703
 
 
81ec3b4
bd0c703
 
81ec3b4
bd0c703
 
 
 
81ec3b4
bd0c703
 
81ec3b4
bd0c703
 
 
81ec3b4
 
 
57bafce
f87f969
 
 
 
 
51348d0
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import streamlit as st
from transformers import pipeline
from ModelDriver import *
import numpy as np

# Add a title
st.title('GPT Detection Demo')
st.write("This is a demo for GPT detection. You can use this demo to test the model. The model is trained on two datasets: OpenGPT and CSAbstract. You can choose the model and dataset in the sidebar.")
st.write("Reference on how we built Roberta Sentinel: https://arxiv.org/abs/2305.07969")

# Add 4 options for 4 models
ModelOption = st.sidebar.selectbox(
    'Which Model do you want to use?',
    ('RobertaSentinel', 'RobertaClassifier'),
)

DatasetOption = st.sidebar.selectbox(
    'Which Dataset the model was trained on?',
    ('OpenGPT', 'CSAbstract'),
)


text = st.text_area('Enter text here (max 500 words)', '')

if st.button('Generate'):
    if ModelOption == 'RobertaSentinel':
        if DatasetOption == 'OpenGPT':
            result = RobertaSentinelOpenGPTInference(text)
            st.write("Model: RobertaSentinelOpenGPT")
        elif DatasetOption == 'CSAbstract':
            result = RobertaSentinelCSAbstractInference(text)
            st.write("Model: RobertaSentinelCSAbstract")

    elif ModelOption == 'RobertaClassifier':
        if DatasetOption == 'OpenGPT':
            result = RobertaClassifierOpenGPTInference(text)
            st.write("Model: RobertaClassifierOpenGPT")
        elif DatasetOption == 'CSAbstract':
            result = RobertaClassifierCSAbstractInference(text)
            st.write("Model: RobertaClassifierCSAbstract")

    Prediction = "Human Written" if not np.argmax(result) else "Machine Generated"

    st.write(f"Prediction: {Prediction} ")
    st.write(f"Probabilty:", max(result))