Spaces:
Running on Zero
Running on Zero
Lord-Raven commited on
Commit ·
a4ca161
1
Parent(s): 36c07e6
Trying to fix things.
Browse files
app.py
CHANGED
|
@@ -21,7 +21,7 @@ tokenizer_name_gpu = "MoritzLaurer/roberta-large-zeroshot-v2.0-c"
|
|
| 21 |
classifier_cpu = pipeline(task="zero-shot-classification", model=model_name_cpu, tokenizer=tokenizer_name_cpu, device="cpu", torch_dtype=torch.bfloat16)
|
| 22 |
classifier_gpu = pipeline(task="zero-shot-classification", model=model_name_gpu, tokenizer=tokenizer_name_gpu, device="cuda", torch_dtype=torch.bfloat16) if torch.cuda.is_available() else classifier_cpu
|
| 23 |
|
| 24 |
-
def
|
| 25 |
|
| 26 |
data = json.loads(data_string)
|
| 27 |
|
|
@@ -53,8 +53,7 @@ def create_sequences(data):
|
|
| 53 |
return [data['sequence'] + '\n' + data['hypothesis_template'].format(label) for label in data['candidate_labels']]
|
| 54 |
|
| 55 |
gradio_interface = gradio.Interface(
|
| 56 |
-
fn =
|
| 57 |
-
api_name="predict",
|
| 58 |
inputs = gradio.Textbox(label="JSON Input"),
|
| 59 |
outputs = gradio.Textbox(label="JSON Output"),
|
| 60 |
title = "Statosphere Backend",
|
|
|
|
| 21 |
classifier_cpu = pipeline(task="zero-shot-classification", model=model_name_cpu, tokenizer=tokenizer_name_cpu, device="cpu", torch_dtype=torch.bfloat16)
|
| 22 |
classifier_gpu = pipeline(task="zero-shot-classification", model=model_name_gpu, tokenizer=tokenizer_name_gpu, device="cuda", torch_dtype=torch.bfloat16) if torch.cuda.is_available() else classifier_cpu
|
| 23 |
|
| 24 |
+
def predict(data_string):
|
| 25 |
|
| 26 |
data = json.loads(data_string)
|
| 27 |
|
|
|
|
| 53 |
return [data['sequence'] + '\n' + data['hypothesis_template'].format(label) for label in data['candidate_labels']]
|
| 54 |
|
| 55 |
gradio_interface = gradio.Interface(
|
| 56 |
+
fn = predict,
|
|
|
|
| 57 |
inputs = gradio.Textbox(label="JSON Input"),
|
| 58 |
outputs = gradio.Textbox(label="JSON Output"),
|
| 59 |
title = "Statosphere Backend",
|