Spaces:
Running
on
Zero
Running
on
Zero
DivEye - PR (fix bugs x4)
#14
by
FloofCat
- opened
app.py
CHANGED
@@ -20,7 +20,27 @@ theme = gr.Theme.from_hub("gstaff/xkcd")
|
|
20 |
|
21 |
# ===========================================================
|
22 |
@spaces.GPU
|
23 |
-
def
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
global model, div_model, div_tokenizer, bi_model, bi_tokenizer
|
25 |
|
26 |
# =====================================================================
|
@@ -91,29 +111,9 @@ def evaluate(text):
|
|
91 |
for f in biscope_features:
|
92 |
diveye_features.append(f)
|
93 |
|
94 |
-
|
95 |
|
96 |
-
|
97 |
-
global loaded, diveye, biscope, model
|
98 |
-
if not loaded:
|
99 |
-
return "β Model not loaded. We require a GPU to run DivEye.", 0.0, pd.DataFrame({
|
100 |
-
"Source": ["AI Generated", "Human Written"],
|
101 |
-
"Probability (%)": [0, 0]
|
102 |
-
})
|
103 |
-
|
104 |
-
text = text.strip()
|
105 |
-
if not text or len(text.split()) < 15:
|
106 |
-
return (
|
107 |
-
"β Please enter some text with at least 15 words.",
|
108 |
-
0.0,
|
109 |
-
pd.DataFrame({
|
110 |
-
"Source": ["AI Generated", "Human Written"],
|
111 |
-
"Probability (%)": [0, 0]
|
112 |
-
})
|
113 |
-
)
|
114 |
-
|
115 |
-
# Call software
|
116 |
-
ai_prob = evaluate(text)
|
117 |
human_prob = 1 - ai_prob
|
118 |
|
119 |
if ai_prob > 0.7:
|
|
|
20 |
|
21 |
# ===========================================================
|
22 |
@spaces.GPU
|
23 |
+
def detect_ai_text(text):
|
24 |
+
global loaded
|
25 |
+
if not loaded:
|
26 |
+
return "β Model not loaded. We require a GPU to run DivEye.", 0.0, pd.DataFrame({
|
27 |
+
"Source": ["AI Generated", "Human Written"],
|
28 |
+
"Probability (%)": [0, 0]
|
29 |
+
})
|
30 |
+
|
31 |
+
text = text.strip()
|
32 |
+
if not text or len(text.split()) < 15:
|
33 |
+
return (
|
34 |
+
"β Please enter some text with at least 15 words.",
|
35 |
+
0.0,
|
36 |
+
pd.DataFrame({
|
37 |
+
"Source": ["AI Generated", "Human Written"],
|
38 |
+
"Probability (%)": [0, 0]
|
39 |
+
})
|
40 |
+
)
|
41 |
+
|
42 |
+
# Call software
|
43 |
+
# ===========================================================
|
44 |
global model, div_model, div_tokenizer, bi_model, bi_tokenizer
|
45 |
|
46 |
# =====================================================================
|
|
|
111 |
for f in biscope_features:
|
112 |
diveye_features.append(f)
|
113 |
|
114 |
+
ai_prob = model.predict_proba([diveye_features])[:, 1][0].item()
|
115 |
|
116 |
+
# ===========================================================
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
human_prob = 1 - ai_prob
|
118 |
|
119 |
if ai_prob > 0.7:
|