demo-app-gradio / app.py
akuysal's picture
Update app.py
bbdd569
raw
history blame
1.36 kB
!pip install gradio
!pip install transformers
import gradio as gr
from transformers import pipeline
def aspects(sentense):
sentense=[sentense]
sentimentdata=sentiment(sentense)
fit_score=process.default_scorer(sentense,fit)
mat_score=process.default_scorer(sentense,material)
price_score=process.default_scorer(sentense,price)
sentimentlabel=sentimentdata[0].get("label")
sentprobability=sentimentdata[0].get("score")
return sentimentlabel,sentprobability,fit_score,price_score,mat_score
pipe = pipeline("sentiment-analysis")
interface=gr.Interface(fn=aspects,inputs=gr.inputs.Textbox(lines=10,placeholder="please insert your text"),
examples=[
["this product and not fitting well to my body and feel scratchy"],
["this fabric is super cool and feel very comfortable "]
],
title="Review Analyzer",
outputs=[gr.outputs.Textbox(type="auto", label="Sentiment"),
gr.outputs.Textbox(type="auto", label="Sentiment score"),
gr.outputs.Textbox(type="auto", label="Fit related score"),
gr.outputs.Textbox(type="auto", label="Price related score"),
gr.outputs.Textbox(type="auto", label="Material related score")],live=True)
interface.launch()