Spaces:
Sleeping
Sleeping
update
Browse files
demo/binary_classifier_demo.py
CHANGED
@@ -7,12 +7,6 @@ import os
|
|
7 |
from model_utils import load_model, classify_text
|
8 |
from binoculars_utils import initialize_binoculars, compute_scores
|
9 |
|
10 |
-
# Initialize Binoculars models
|
11 |
-
bino_chat, bino_coder = initialize_binoculars()
|
12 |
-
|
13 |
-
# Load binary classifier model
|
14 |
-
model, scaler, label_encoder, imputer = load_model()
|
15 |
-
|
16 |
DEVICE = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
17 |
MINIMUM_TOKENS = 200
|
18 |
|
@@ -54,6 +48,12 @@ def run_binary_classifier(text, show_analysis=False):
|
|
54 |
if len(text.strip()) < MINIMUM_TOKENS:
|
55 |
return gr.Markdown(f"Текст слишком короткий. Требуется минимум {MINIMUM_TOKENS} символов."), None, None
|
56 |
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
# Compute scores using binoculars
|
58 |
scores = compute_scores(text, bino_chat, bino_coder)
|
59 |
|
|
|
7 |
from model_utils import load_model, classify_text
|
8 |
from binoculars_utils import initialize_binoculars, compute_scores
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
DEVICE = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
11 |
MINIMUM_TOKENS = 200
|
12 |
|
|
|
48 |
if len(text.strip()) < MINIMUM_TOKENS:
|
49 |
return gr.Markdown(f"Текст слишком короткий. Требуется минимум {MINIMUM_TOKENS} символов."), None, None
|
50 |
|
51 |
+
# Initialize Binoculars models
|
52 |
+
bino_chat, bino_coder = initialize_binoculars()
|
53 |
+
|
54 |
+
# Load binary classifier model
|
55 |
+
model, scaler, label_encoder, imputer = load_model()
|
56 |
+
|
57 |
# Compute scores using binoculars
|
58 |
scores = compute_scores(text, bino_chat, bino_coder)
|
59 |
|