File size: 1,667 Bytes
51348d0
f87f969
bd0c703
 
f87f969
 
 
81ec3b4
f87f969
 
bd0c703
57bafce
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
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.")

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