suinY00N commited on
Commit
5239a8a
โ€ข
1 Parent(s): 77b4277

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Assuming you want to use a specific model for sentiment analysis; if not, the pipeline defaults to an English model.
5
+ # For multilingual support including Korean, you might need to specify a model that supports Korean.
6
+ # For this example, we'll proceed with the default model for demonstration purposes.
7
+ sentiment_analysis = pipeline("sentiment-analysis")
8
+
9
+ def get_sentiment(text):
10
+ # Perform sentiment analysis on the input text
11
+ result = sentiment_analysis(text)
12
+ # Format the result to display it nicely
13
+ formatted_result = f"Label: {result[0]['label']}, Score: {result[0]['score']:.4f}"
14
+ return formatted_result
15
+
16
+ # Define the Gradio interface
17
+ interface = gr.Interface(
18
+ fn=get_sentiment, # function to call
19
+ inputs=gr.inputs.Textbox(lines=2, placeholder="์—ฌ๊ธฐ์— ํ…์ŠคํŠธ๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”..."), # input component
20
+ outputs="text", # output component
21
+ title="Text Sentiment Analysis", # title of the interface
22
+ description="This app analyzes the sentiment of input text. Enter text to see if it's positive or negative." # description
23
+ )
24
+
25
+ # Launch the Gradio app
26
+ interface.launch()