Spaces:
Sleeping
Sleeping
updated app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
bert_model = pipeline("sentiment-analysis")
|
| 5 |
+
distilbert_model = pipeline("sentiment-analysis", model="distilbert-base-uncased-finetuned-sst-2-english")
|
| 6 |
+
|
| 7 |
+
def compare_models(text):
|
| 8 |
+
result1 = bert_model(text)[0]
|
| 9 |
+
result2 = distilbert_model(text)[0]
|
| 10 |
+
|
| 11 |
+
return(
|
| 12 |
+
f"BERT -> {result1['label']} {round(result1['score'],2)}\n"
|
| 13 |
+
f"DistilBERT -> {result2['label']} {round(result2['score'],2)}"
|
| 14 |
+
)
|
| 15 |
+
|
| 16 |
+
iface = gr.Interface(
|
| 17 |
+
fn=compare_models,
|
| 18 |
+
inputs=gr.Textbox(label="Enter Text"),
|
| 19 |
+
outputs="text",
|
| 20 |
+
title="NLP Model Comparision",
|
| 21 |
+
description="Compare predictions of multiple NLP models"
|
| 22 |
+
)
|
| 23 |
+
|
| 24 |
+
iface.launch()
|