File size: 904 Bytes
cda2e2d
 
 
 
9bf10c8
 
cda2e2d
0ea7249
cda2e2d
 
 
0ea7249
cda2e2d
 
9bf10c8
cda2e2d
 
606e889
 
cda2e2d
 
 
 
 
 
 
 
 
a50c1ce
cda2e2d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import tensorflow as tf
from pathlib import Path
from huggingface_hub import hf_hub_download
import os
import keras_hub



model_path = hf_hub_download(
    repo_id="aikenml/AI-text-humanizer-deberta",
    filename="deberta_classifier.keras",
    # token=os.getenv("HF_TOKEN")  # модель публичный, токен керек емес
)


# Загружаем модель (без компиляции, чтобы убрать предупреждения)
model = tf.keras.models.load_model(model_path, compile=False)

def debert_classifier(text):
    predictions = model.predict([text])

    # Show results
    for text, pred in zip([text], predictions):
        # label = "AI-generated" if pred > 0.5 else "Human-written"
        # print(f"{text} --> {label} (score={pred[0]:.4f})")
        # return label
        # return "hello"
        # return 0.7
        print(pred)
        return pred