File size: 1,178 Bytes
5239a8a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
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()
|