Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2,12 +2,13 @@ import gradio as gr
|
|
2 |
from transformers import pipeline
|
3 |
import concurrent.futures
|
4 |
import ktrain
|
|
|
5 |
|
6 |
zero_shot = pipeline("zero-shot-classification")
|
7 |
distilbert = ktrain.load_predictor("models/distilbert-base-uncased-finetuned-internet-provider")
|
8 |
|
9 |
def zero_shot_predict(text):
|
10 |
-
labels = ["Slow
|
11 |
preds = zero_shot(text, candidate_labels=labels)
|
12 |
return {label: float(pred) for label, pred in zip(preds["labels"], preds["scores"])}
|
13 |
|
@@ -17,6 +18,7 @@ def distilbert_predict(text):
|
|
17 |
return {label: float(pred) for label, pred in zip(labels, preds)}
|
18 |
|
19 |
def predict(text):
|
|
|
20 |
with concurrent.futures.ThreadPoolExecutor(max_workers=2) as executor:
|
21 |
zero_shot_future = executor.submit(zero_shot_predict, text)
|
22 |
distilbert_future = executor.submit(distilbert_predict, text)
|
|
|
2 |
from transformers import pipeline
|
3 |
import concurrent.futures
|
4 |
import ktrain
|
5 |
+
import time
|
6 |
|
7 |
zero_shot = pipeline("zero-shot-classification")
|
8 |
distilbert = ktrain.load_predictor("models/distilbert-base-uncased-finetuned-internet-provider")
|
9 |
|
10 |
def zero_shot_predict(text):
|
11 |
+
labels = ["Slow Connection", "Billing", "Setup", "No Connectivity"]
|
12 |
preds = zero_shot(text, candidate_labels=labels)
|
13 |
return {label: float(pred) for label, pred in zip(preds["labels"], preds["scores"])}
|
14 |
|
|
|
18 |
return {label: float(pred) for label, pred in zip(labels, preds)}
|
19 |
|
20 |
def predict(text):
|
21 |
+
time.sleep(1)
|
22 |
with concurrent.futures.ThreadPoolExecutor(max_workers=2) as executor:
|
23 |
zero_shot_future = executor.submit(zero_shot_predict, text)
|
24 |
distilbert_future = executor.submit(distilbert_predict, text)
|