sshouq / app.py
shouq0i's picture
Rename demo.py to app.py
cfb044a verified
raw
history blame contribute delete
No virus
974 Bytes
# -*- coding: utf-8 -*-
"""demo.ipynb
Automatically generated by Colab.
Original file is located at
https://colab.research.google.com/drive/19sodc0ANzqRgZ0VzMGXr4YQ3fvUvxyjv
"""
# Use a pipeline as a high-level helper
from transformers import pipeline
sentiment_analysis = pipeline("text-classification", model="avichr/heBERT_sentiment_analysis")
def analyze_sentiment(text):
results = sentiment_analysis(text)
for result in results:
print(f"Label: {result['label']}, Score: {result['score']}")
texts = [
"Worst rental I ever got"
"I really enjoyed my stay !"
]
analyze_sentiment(texts)
import gradio as gr
from transformers import pipeline
interface = gr.Interface(
fn=analyze_sentiment,
inputs=gr.Textbox(lines=2, placeholder="Enter your review or statement here..."),
outputs=[
gr.Textbox(label="Sentiment"),
gr.Number(label="Score")
],
title="Sentiment Analysis Score"
)
interface.launch()