Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -10,6 +10,24 @@ def interpret_pred(pred):
|
|
10 |
is_ai_percent = round(100 * interpreted_pred)
|
11 |
return result, is_ai_percent
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
def main(text_sentence):
|
15 |
import torch
|
@@ -25,11 +43,16 @@ def main(text_sentence):
|
|
25 |
|
26 |
predict = model.forward(input_ids)[0]
|
27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
result = (
|
29 |
-
"
|
30 |
-
.format(
|
31 |
)
|
32 |
-
|
33 |
return result
|
34 |
|
35 |
|
|
|
10 |
is_ai_percent = round(100 * interpreted_pred)
|
11 |
return result, is_ai_percent
|
12 |
|
13 |
+
def interpret_pred_with_sensibility(pred):
|
14 |
+
low_bond = -6.748472
|
15 |
+
high_bound = 6.7176056
|
16 |
+
pred_value = pred[0][1].item()
|
17 |
+
interpreted_pred = (pred_value - low_bond) / (high_bound - low_bond)
|
18 |
+
if interpreted_pred < 0.5:
|
19 |
+
proba = "très faible"
|
20 |
+
elif interpreted_pred < 0.6:
|
21 |
+
proba = "faible"
|
22 |
+
elif interpreted_pred < 0.8:
|
23 |
+
proba = "modérée"
|
24 |
+
elif interpreted_pred < 0.95:
|
25 |
+
proba = "élevée"
|
26 |
+
else:
|
27 |
+
proba = "très élevée"
|
28 |
+
|
29 |
+
return proba
|
30 |
+
|
31 |
|
32 |
def main(text_sentence):
|
33 |
import torch
|
|
|
43 |
|
44 |
predict = model.forward(input_ids)[0]
|
45 |
|
46 |
+
#result = (
|
47 |
+
# "Résultat : {}.\nCe texte a {}% de chances d'avoir été généré par de l'IA"
|
48 |
+
# .format(interpret_pred(predict)[0], interpret_pred(predict)[1])
|
49 |
+
#)
|
50 |
+
|
51 |
+
proba = interpret_pred_with_sensibility(predict)
|
52 |
result = (
|
53 |
+
"La probabilité que ce texte a été généré par de l'IA est {}"
|
54 |
+
.format(proba)
|
55 |
)
|
|
|
56 |
return result
|
57 |
|
58 |
|