Spaces:
Runtime error
Runtime error
Commit
Β·
676ab2f
1
Parent(s):
20dfed1
Update app.py
Browse files
app.py
CHANGED
|
@@ -64,8 +64,8 @@ def predict(query):
|
|
| 64 |
logits = model(tokens.to(device), attention_mask=mask.to(device))[0]
|
| 65 |
probs = logits.softmax(dim=-1)
|
| 66 |
|
| 67 |
-
real, fake = probs.detach().cpu().flatten().numpy().tolist() # Hello-SimpleAI/chatgpt-detector-roberta
|
| 68 |
-
|
| 69 |
|
| 70 |
return real
|
| 71 |
|
|
@@ -84,9 +84,6 @@ def findRealProb(text):
|
|
| 84 |
realProb = ans/cnt
|
| 85 |
return {"Real": realProb, "Fake": 1-realProb}, results
|
| 86 |
|
| 87 |
-
TXT_TO_INSPECT=None
|
| 88 |
-
def inspect_content(text):
|
| 89 |
-
TXT_TO_INSPECT=text
|
| 90 |
|
| 91 |
st.markdown(""" <style> .appview-container .main .block-container {
|
| 92 |
max-width: 100%;
|
|
@@ -122,7 +119,15 @@ if choose == "Inspect Content":
|
|
| 122 |
with col2: # To display brand logo
|
| 123 |
st.image('./inspection-1.jpg', width=100 )
|
| 124 |
|
| 125 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
Cristiano Ronaldo is a Portuguese professional soccer player who currently plays
|
| 127 |
as a forward for Manchester United and the Portugal national team. He is widely
|
| 128 |
considered one of the greatest soccer players of all time, having won numerous
|
|
@@ -136,9 +141,10 @@ if choose == "Inspect Content":
|
|
| 136 |
three seasons before returning to Manchester United in 2021. He has also had
|
| 137 |
a successful international career with the Portugal national team, having won
|
| 138 |
the UEFA European Championship in 2016 and the UEFA Nations League in 2019.
|
| 139 |
-
''',
|
|
|
|
| 140 |
|
| 141 |
-
if
|
| 142 |
with st.spinner('Loading the model..'):
|
| 143 |
model.to(device)
|
| 144 |
|
|
@@ -148,9 +154,10 @@ if choose == "Inspect Content":
|
|
| 148 |
# print(audio.shape)
|
| 149 |
predictions=findRealProb(txt)
|
| 150 |
print('prediction_value',predictions)
|
| 151 |
-
if predictions[0]['Fake'] > 0.
|
| 152 |
# st.error(f"The Sample is spoof: \n Confidence {(prediction_value) }%", icon="π¨")
|
| 153 |
st.error(f"This text is AI generated", icon="π¨")
|
|
|
|
| 154 |
else:
|
| 155 |
st.success(f"This text is real", icon="β
")
|
| 156 |
|
|
@@ -214,7 +221,7 @@ if choose == "Contact":
|
|
| 214 |
Email=st.text_input(label='Please Enter Your Email') #Collect user feedback
|
| 215 |
Message=st.text_input(label='Please Enter Your Message') #Collect user feedback
|
| 216 |
submitted = st.form_submit_button('Submit')
|
| 217 |
-
if submitted:
|
| 218 |
-
|
| 219 |
|
| 220 |
|
|
|
|
| 64 |
logits = model(tokens.to(device), attention_mask=mask.to(device))[0]
|
| 65 |
probs = logits.softmax(dim=-1)
|
| 66 |
|
| 67 |
+
# real, fake = probs.detach().cpu().flatten().numpy().tolist() # Hello-SimpleAI/chatgpt-detector-roberta
|
| 68 |
+
fake, real = probs.detach().cpu().flatten().numpy().tolist() # PirateXX/AI-Content-Detector-V2
|
| 69 |
|
| 70 |
return real
|
| 71 |
|
|
|
|
| 84 |
realProb = ans/cnt
|
| 85 |
return {"Real": realProb, "Fake": 1-realProb}, results
|
| 86 |
|
|
|
|
|
|
|
|
|
|
| 87 |
|
| 88 |
st.markdown(""" <style> .appview-container .main .block-container {
|
| 89 |
max-width: 100%;
|
|
|
|
| 119 |
with col2: # To display brand logo
|
| 120 |
st.image('./inspection-1.jpg', width=100 )
|
| 121 |
|
| 122 |
+
# txt = st.text_area('Text to analyze', '''
|
| 123 |
+
# It was the best of times, it was the worst of times, it was
|
| 124 |
+
# the age of wisdom, it was the age of foolishness, it was
|
| 125 |
+
# the epoch of belief, it was the epoch of incredulity, it
|
| 126 |
+
# was the season of Light, it was the season of Darkness, it
|
| 127 |
+
# was the spring of hope, it was the winter of despair, (...)
|
| 128 |
+
# ''')
|
| 129 |
+
|
| 130 |
+
txt = st.text_area('Add Text here','''
|
| 131 |
Cristiano Ronaldo is a Portuguese professional soccer player who currently plays
|
| 132 |
as a forward for Manchester United and the Portugal national team. He is widely
|
| 133 |
considered one of the greatest soccer players of all time, having won numerous
|
|
|
|
| 141 |
three seasons before returning to Manchester United in 2021. He has also had
|
| 142 |
a successful international career with the Portugal national team, having won
|
| 143 |
the UEFA European Championship in 2016 and the UEFA Nations League in 2019.
|
| 144 |
+
''', height=300, max_chars=2000)
|
| 145 |
+
|
| 146 |
|
| 147 |
+
if st.button('Analyze Content'): # st.session_state.input_text is not None
|
| 148 |
with st.spinner('Loading the model..'):
|
| 149 |
model.to(device)
|
| 150 |
|
|
|
|
| 154 |
# print(audio.shape)
|
| 155 |
predictions=findRealProb(txt)
|
| 156 |
print('prediction_value',predictions)
|
| 157 |
+
if predictions[0]['Fake'] > 0.90:
|
| 158 |
# st.error(f"The Sample is spoof: \n Confidence {(prediction_value) }%", icon="π¨")
|
| 159 |
st.error(f"This text is AI generated", icon="π¨")
|
| 160 |
+
|
| 161 |
else:
|
| 162 |
st.success(f"This text is real", icon="β
")
|
| 163 |
|
|
|
|
| 221 |
Email=st.text_input(label='Please Enter Your Email') #Collect user feedback
|
| 222 |
Message=st.text_input(label='Please Enter Your Message') #Collect user feedback
|
| 223 |
submitted = st.form_submit_button('Submit')
|
| 224 |
+
# if submitted:
|
| 225 |
+
# st.write('Thanks for your contacting us. We will respond to your questions or inquiries as soon as possible!')
|
| 226 |
|
| 227 |
|