mahebabu commited on
Commit
3acb337
·
verified ·
1 Parent(s): 10e5a26

added app and req

Browse files
Files changed (2) hide show
  1. app.py +24 -0
  2. requirements.txt +3 -0
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()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ gradio
2
+ transformers
3
+ torch