aikenml commited on
Commit
cda2e2d
·
verified ·
1 Parent(s): 2154dc8

Update scripts/classifier.py

Browse files
Files changed (1) hide show
  1. scripts/classifier.py +25 -1
scripts/classifier.py CHANGED
@@ -1,4 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
 
2
  def debert_classifier(text):
3
  # ....
4
- return 0.7
 
 
 
 
 
 
 
 
 
 
 
1
+ import tensorflow as tf
2
+ from pathlib import Path
3
+ from huggingface_hub import hf_hub_download
4
+ import os
5
+
6
+ # Если модель приватная — добавь HF_TOKEN в переменные окружения (Settings → Secrets)
7
+ model_path = hf_hub_download(
8
+ repo_id="aikenml/AI-text-humanizer-deberta",
9
+ filename="deberta_classifier.keras",
10
+ # token=os.getenv("HF_TOKEN") # можно убрать, если репозиторий публичный
11
+ )
12
+
13
+ # Загружаем модель (без компиляции, чтобы убрать предупреждения)
14
+ model = tf.keras.models.load_model(model_path, compile=False)
15
 
16
  def debert_classifier(text):
17
  # ....
18
+ # Predict
19
+ predictions = model.predict([text])
20
+
21
+ # Show results
22
+ for text, pred in zip([text], predictions):
23
+ # label = "AI-generated" if pred > 0.5 else "Human-written"
24
+ # print(f"{text} --> {label} (score={pred[0]:.4f})")
25
+ # return label
26
+ # return "hello"
27
+ # return 0.7
28
+ return pred