sent_suin / app.py
suinY00N's picture
Create app.py
5239a8a verified
raw
history blame
1.18 kB
import gradio as gr
from transformers import pipeline
# Assuming you want to use a specific model for sentiment analysis; if not, the pipeline defaults to an English model.
# For multilingual support including Korean, you might need to specify a model that supports Korean.
# For this example, we'll proceed with the default model for demonstration purposes.
sentiment_analysis = pipeline("sentiment-analysis")
def get_sentiment(text):
# Perform sentiment analysis on the input text
result = sentiment_analysis(text)
# Format the result to display it nicely
formatted_result = f"Label: {result[0]['label']}, Score: {result[0]['score']:.4f}"
return formatted_result
# Define the Gradio interface
interface = gr.Interface(
fn=get_sentiment, # function to call
inputs=gr.inputs.Textbox(lines=2, placeholder="์—ฌ๊ธฐ์— ํ…์ŠคํŠธ๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”..."), # input component
outputs="text", # output component
title="Text Sentiment Analysis", # title of the interface
description="This app analyzes the sentiment of input text. Enter text to see if it's positive or negative." # description
)
# Launch the Gradio app
interface.launch()