Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -316,25 +316,6 @@ if press_me_button:
|
|
| 316 |
"human": "Human-Written"
|
| 317 |
}
|
| 318 |
|
| 319 |
-
|
| 320 |
-
max_cnn_prob_name = sorted_probabilities[0][0]
|
| 321 |
-
max_cnn_prob = float(sorted_probabilities[0][1])
|
| 322 |
-
|
| 323 |
-
def classify_human_or_ai(ridge_prob, extra_trees_prob, cnn_prob):
|
| 324 |
-
threshold = 0.5 # You can adjust this threshold as needed
|
| 325 |
-
# Convert to float before comparison
|
| 326 |
-
if max(float(ridge_prob), float(extra_trees_prob), float(cnn_prob)) < threshold:
|
| 327 |
-
return "Human-Written"
|
| 328 |
-
else:
|
| 329 |
-
return "AI Generated"
|
| 330 |
-
|
| 331 |
-
# Determine the classification
|
| 332 |
-
classification = classify_human_or_ai(max_cnn_prob, max(ridge_prediction), max(extra_trees_prediction))
|
| 333 |
-
|
| 334 |
-
# Display the classification result
|
| 335 |
-
with st.expander("Classification Result"):
|
| 336 |
-
st.write(f"The input text is classified as: **{classification}**")
|
| 337 |
-
|
| 338 |
cnn_name, ridge_name, extra_trees_name = get_author_display_name(predicted_author, ridge_prediction, extra_trees_prediction)
|
| 339 |
with st.expander("Prediction Details (Click Here)..."):
|
| 340 |
st.write(f"Ridge: {ridge_name}")
|
|
@@ -347,15 +328,12 @@ if press_me_button:
|
|
| 347 |
st.write(f"{display_name}: {prob * 100:.2f}%")
|
| 348 |
st.progress(float(prob))
|
| 349 |
|
| 350 |
-
|
|
|
|
| 351 |
|
| 352 |
if word_count < 10.0 or word_count > 1081.0:
|
| 353 |
st.warning("For better prediction input texts between 10 and 1081", icon="ℹ️")
|
| 354 |
|
| 355 |
-
elif classification == "Human-Written":
|
| 356 |
-
st.success("The input text is classified as **Human-Written**.", icon="✅")
|
| 357 |
-
st.info("We are quite confident in the accuracy of this result.", icon="ℹ️")
|
| 358 |
-
|
| 359 |
elif word_count < 256:
|
| 360 |
if ridge_prediction == extra_trees_prediction == predicted_author:
|
| 361 |
st.success(f"Most likely written by: **{cnn_name}**", icon="✅")
|
|
@@ -398,6 +376,7 @@ if press_me_button:
|
|
| 398 |
st.success(f"2- **{cnn_name}**", icon="✅")
|
| 399 |
st.success(f"3- **{extra_trees_name}**", icon="✅")
|
| 400 |
|
|
|
|
| 401 |
|
| 402 |
|
| 403 |
# Using expander to make FAQ sections
|
|
@@ -454,3 +433,4 @@ with st.expander("Can I use this as evidence?"):
|
|
| 454 |
""")
|
| 455 |
|
| 456 |
|
|
|
|
|
|
| 316 |
"human": "Human-Written"
|
| 317 |
}
|
| 318 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 319 |
cnn_name, ridge_name, extra_trees_name = get_author_display_name(predicted_author, ridge_prediction, extra_trees_prediction)
|
| 320 |
with st.expander("Prediction Details (Click Here)..."):
|
| 321 |
st.write(f"Ridge: {ridge_name}")
|
|
|
|
| 328 |
st.write(f"{display_name}: {prob * 100:.2f}%")
|
| 329 |
st.progress(float(prob))
|
| 330 |
|
| 331 |
+
max_cnn_prob_name = sorted_probabilities[0][0]
|
| 332 |
+
max_cnn_prob = float(sorted_probabilities[0][1])
|
| 333 |
|
| 334 |
if word_count < 10.0 or word_count > 1081.0:
|
| 335 |
st.warning("For better prediction input texts between 10 and 1081", icon="ℹ️")
|
| 336 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 337 |
elif word_count < 256:
|
| 338 |
if ridge_prediction == extra_trees_prediction == predicted_author:
|
| 339 |
st.success(f"Most likely written by: **{cnn_name}**", icon="✅")
|
|
|
|
| 376 |
st.success(f"2- **{cnn_name}**", icon="✅")
|
| 377 |
st.success(f"3- **{extra_trees_name}**", icon="✅")
|
| 378 |
|
| 379 |
+
|
| 380 |
|
| 381 |
|
| 382 |
# Using expander to make FAQ sections
|
|
|
|
| 433 |
""")
|
| 434 |
|
| 435 |
|
| 436 |
+
|