Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,30 +1,17 @@
|
|
1 |
-
|
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 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
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()
|
|