MAS-AI-0000 commited on
Commit
707b788
·
verified ·
1 Parent(s): ff4bbc9

Update textPreprocess.py

Browse files
Files changed (1) hide show
  1. textPreprocess.py +16 -6
textPreprocess.py CHANGED
@@ -99,9 +99,13 @@ def predict_text(text: str, max_length: int = None):
99
  pred = predictions[0]
100
  # pred.label is "Human" or "AI"
101
  # Map to "Human" or "Ai" to match previous API
102
- label = pred.label
103
- if label == "AI":
104
- label = "Ai"
 
 
 
 
105
 
106
  # Confidence logic:
107
  # If label is Human, use probability_human
@@ -141,9 +145,15 @@ def predict_batch(texts, batch_size=16):
141
  results = []
142
  for text, pred in zip(texts, predictions):
143
  label = pred.label
144
- if label == "AI":
145
- label = "Ai"
146
- confidence = pred.probability_human if label == "Human" else pred.probability_ai
 
 
 
 
 
 
147
 
148
  results.append({
149
  "text": text,
 
99
  pred = predictions[0]
100
  # pred.label is "Human" or "AI"
101
  # Map to "Human" or "Ai" to match previous API
102
+ # Determine label based on higher confidence
103
+ if pred.probability_ai > pred.probability_human:
104
+ label = "AI"
105
+ confidence = pred.probability_ai
106
+ else:
107
+ label = "Human"
108
+ confidence = pred.probability_human
109
 
110
  # Confidence logic:
111
  # If label is Human, use probability_human
 
145
  results = []
146
  for text, pred in zip(texts, predictions):
147
  label = pred.label
148
+
149
+ # Determine label based on higher confidence
150
+ if pred.probability_ai > pred.probability_human:
151
+ label = "AI"
152
+ confidence = pred.probability_ai
153
+ else:
154
+ label = "Human"
155
+ confidence = pred.probability_human
156
+
157
 
158
  results.append({
159
  "text": text,