Update app.py
Browse files
app.py
CHANGED
|
@@ -32,12 +32,9 @@ def process_input(text_input, labels_or_premise, mode):
|
|
| 32 |
results = {label: score for label, score in zip(prediction['labels'], prediction['scores'])}
|
| 33 |
return results, ''
|
| 34 |
else: # NLI mode
|
| 35 |
-
|
| 36 |
-
results
|
| 37 |
-
|
| 38 |
-
"contradiction": prediction.get("score", 0) if prediction.get("label") == "contradiction" else 0,
|
| 39 |
-
"neutral": prediction.get("score", 0) if prediction.get("label") == "neutral" else 0
|
| 40 |
-
}
|
| 41 |
return results, ''
|
| 42 |
|
| 43 |
def update_interface(mode):
|
|
@@ -98,19 +95,21 @@ with gr.Blocks() as demo:
|
|
| 98 |
gr.Markdown(label="📈 Analysis", visible=False)
|
| 99 |
]
|
| 100 |
|
| 101 |
-
|
| 102 |
gr.Examples(
|
| 103 |
examples=zero_shot_examples,
|
| 104 |
inputs=[text_input, labels_or_premise],
|
| 105 |
-
label="Zero-Shot Classification Examples"
|
|
|
|
| 106 |
)
|
| 107 |
-
|
| 108 |
with gr.Column(variant="panel") as nli_examples_panel:
|
| 109 |
gr.Examples(
|
| 110 |
examples=nli_examples,
|
| 111 |
inputs=[text_input, labels_or_premise],
|
| 112 |
-
label="Natural Language Inference Examples"
|
| 113 |
-
|
|
|
|
| 114 |
|
| 115 |
def update_visibility(mode):
|
| 116 |
return (
|
|
|
|
| 32 |
results = {label: score for label, score in zip(prediction['labels'], prediction['scores'])}
|
| 33 |
return results, ''
|
| 34 |
else: # NLI mode
|
| 35 |
+
pred=text_pair='there is a black cat')],return_all_scores=True)
|
| 36 |
+
results= {pred['label']:pred['score'] for pred in pred}
|
| 37 |
+
|
|
|
|
|
|
|
|
|
|
| 38 |
return results, ''
|
| 39 |
|
| 40 |
def update_interface(mode):
|
|
|
|
| 95 |
gr.Markdown(label="📈 Analysis", visible=False)
|
| 96 |
]
|
| 97 |
|
| 98 |
+
with gr.Column(variant="panel") as zero_shot_examples_panel:
|
| 99 |
gr.Examples(
|
| 100 |
examples=zero_shot_examples,
|
| 101 |
inputs=[text_input, labels_or_premise],
|
| 102 |
+
label="Zero-Shot Classification Examples",
|
| 103 |
+
headers=["Input Text", "Categories"] # Add headers
|
| 104 |
)
|
| 105 |
+
|
| 106 |
with gr.Column(variant="panel") as nli_examples_panel:
|
| 107 |
gr.Examples(
|
| 108 |
examples=nli_examples,
|
| 109 |
inputs=[text_input, labels_or_premise],
|
| 110 |
+
label="Natural Language Inference Examples",
|
| 111 |
+
headers=["Premise", "Hypothesis"] # Add headers
|
| 112 |
+
)
|
| 113 |
|
| 114 |
def update_visibility(mode):
|
| 115 |
return (
|