grimzaeye commited on
Commit
6162193
β€’
1 Parent(s): fefe83f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -5
app.py CHANGED
@@ -1,12 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
  from transformers import pipeline
3
 
 
4
  sentiment = pipeline('sentiment-analysis')
5
 
6
- # def get_sentiment(input):
7
- # response =
8
- def greet(name):
9
- return "Hello " + name + "!!"
 
 
 
 
 
10
 
11
- iface = gr.Interface(fn=greet, title="Sentiment Analysis", inputs="text", outputs="text")
12
  iface.launch()
 
1
+ # import gradio as gr
2
+ # from transformers import pipeline
3
+
4
+ # sentiment = pipeline('sentiment-analysis')
5
+
6
+ # # def get_sentiment(input):
7
+ # # response =
8
+ # def greet(name):
9
+ # return "Hello " + name + "!!"
10
+
11
+ # iface = gr.Interface(fn=greet, title="Sentiment Analysis", inputs="text", outputs="text")
12
+ # iface.launch()
13
+
14
  import gradio as gr
15
  from transformers import pipeline
16
 
17
+ # Hugging Faceμ—μ„œ μ œκ³΅ν•˜λŠ” sentiment-analysis νŒŒμ΄ν”„λΌμΈ λ‘œλ“œ
18
  sentiment = pipeline('sentiment-analysis')
19
 
20
+ # μž…λ ₯ ν…μŠ€νŠΈμ— λŒ€ν•΄ 감정 뢄석을 μˆ˜ν–‰ν•˜λŠ” ν•¨μˆ˜
21
+ def get_sentiment(input_text):
22
+ # sentiment-analysis λͺ¨λΈμ„ μ‚¬μš©ν•˜μ—¬ μž…λ ₯ 받은 ν…μŠ€νŠΈμ˜ 감정을 뢄석
23
+ result = sentiment(input_text)
24
+ # κ²°κ³ΌλŠ” 리슀트 ν˜•νƒœλ‘œ λ°˜ν™˜λ˜λ©°, 첫 번째 결과의 λ ˆμ΄λΈ”κ³Ό 점수λ₯Ό ν¬λ§·νŒ…ν•˜μ—¬ λ°˜ν™˜
25
+ return f"Label: {result[0]['label']}, Score: {result[0]['score']:.2f}"
26
+
27
+ # Gradio μΈν„°νŽ˜μ΄μŠ€ μ„€μ •
28
+ iface = gr.Interface(fn=get_sentiment, title="Sentiment Analysis", inputs="text", outputs="text")
29
 
30
+ # μΈν„°νŽ˜μ΄μŠ€ μ‹€ν–‰
31
  iface.launch()