akuysal commited on
Commit
080ae89
1 Parent(s): bbdd569

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -26
app.py CHANGED
@@ -1,30 +1,17 @@
1
- !pip install gradio
2
- !pip install transformers
3
-
4
  import gradio as gr
5
  from transformers import pipeline
6
-
7
- def aspects(sentense):
8
- sentense=[sentense]
9
- sentimentdata=sentiment(sentense)
10
- fit_score=process.default_scorer(sentense,fit)
11
- mat_score=process.default_scorer(sentense,material)
12
- price_score=process.default_scorer(sentense,price)
13
- sentimentlabel=sentimentdata[0].get("label")
14
- sentprobability=sentimentdata[0].get("score")
15
- return sentimentlabel,sentprobability,fit_score,price_score,mat_score
16
 
17
  pipe = pipeline("sentiment-analysis")
18
- interface=gr.Interface(fn=aspects,inputs=gr.inputs.Textbox(lines=10,placeholder="please insert your text"),
19
- examples=[
20
- ["this product and not fitting well to my body and feel scratchy"],
21
- ["this fabric is super cool and feel very comfortable "]
22
-
23
- ],
24
- title="Review Analyzer",
25
- outputs=[gr.outputs.Textbox(type="auto", label="Sentiment"),
26
- gr.outputs.Textbox(type="auto", label="Sentiment score"),
27
- gr.outputs.Textbox(type="auto", label="Fit related score"),
28
- gr.outputs.Textbox(type="auto", label="Price related score"),
29
- gr.outputs.Textbox(type="auto", label="Material related score")],live=True)
30
- interface.launch()
 
1
+ # gradio demo
 
 
2
  import gradio as gr
3
  from transformers import pipeline
 
 
 
 
 
 
 
 
 
 
4
 
5
  pipe = pipeline("sentiment-analysis")
6
+
7
+ def predict(text):
8
+ return pipe(text)[0]["label"]
9
+
10
+ iface = gr.Interface(
11
+ fn=predict,
12
+ inputs='text',
13
+ outputs='text',
14
+ examples=[["The movie was amazing"]]
15
+ )
16
+
17
+ iface.launch()