akuysal commited on
Commit
6a2d61d
1 Parent(s): 5b778fe

Update app.py

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