File size: 2,534 Bytes
51348d0
f87f969
bd0c703
 
f87f969
 
 
20cc32e
2bb8a76
f87f969
20cc32e
 
 
 
 
bd0c703
 
81ec3b4
2bb8a76
f87f969
 
 
2bb8a76
f87f969
20cc32e
 
f87f969
2bb8a76
 
 
 
 
 
 
 
20cc32e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2bb8a76
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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. There are 3 variations of the Roberta Classifier Model, The model was trained on CHEAT, GPABenchmark, OpenGPT datasets. They are all in the domain of Scientific Abstract. You can choose dataset variation of the model on 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?',
#     ('RobertaClassifier'),
# )

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


text = st.text_area('Enter text here (max 512 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")

    # if ModelOption == 'RobertaClassifier':
    #     if DatasetOption == 'OpenGPT':
    #         result = RobertaClassifierOpenGPTInference(text)
    #         st.write("Model: RobertaClassifierOpenGPT")
    #     elif DatasetOption == 'GPABenchmark':
    #         result = RobertaClassifierGPABenchmarkInference(text)
    #         st.write("Model: RobertaClassifierGPABenchmark")
    #     elif DatasetOption == 'CHEAT':
    #         result = RobertaClassifierCHEATInference(text)
    #         st.write("Model: RobertaClassifierCHEAT")

    if DatasetOption == 'OpenGPT':
        result = RobertaClassifierOpenGPTInference(text)
        st.write("Model: RobertaClassifierOpenGPT")
    elif DatasetOption == 'GPABenchmark':
        result = RobertaClassifierGPABenchmarkInference(text)
        st.write("Model: RobertaClassifierGPABenchmark")
    elif DatasetOption == 'CHEAT':
        result = RobertaClassifierCHEATInference(text)
        st.write("Model: RobertaClassifierCHEAT")


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

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