# import gradio as gr | |
# from transformers import pipeline | |
# sentiment = pipeline('sentiment-analysis') | |
# # def get_sentiment(input): | |
# # response = | |
# def greet(name): | |
# return "Hello " + name + "!!" | |
# iface = gr.Interface(fn=greet, title="Sentiment Analysis", inputs="text", outputs="text") | |
# iface.launch() | |
import gradio as gr | |
from transformers import pipeline | |
# Hugging Faceμμ μ 곡νλ sentiment-analysis νμ΄νλΌμΈ λ‘λ | |
sentiment = pipeline('sentiment-analysis') | |
# μ λ ₯ ν μ€νΈμ λν΄ κ°μ λΆμμ μννλ ν¨μ | |
def get_sentiment(input_text): | |
# sentiment-analysis λͺ¨λΈμ μ¬μ©νμ¬ μ λ ₯ λ°μ ν μ€νΈμ κ°μ μ λΆμ | |
result = sentiment(input_text) | |
# κ²°κ³Όλ 리μ€νΈ ννλ‘ λ°νλλ©°, 첫 λ²μ§Έ κ²°κ³Όμ λ μ΄λΈκ³Ό μ μλ₯Ό ν¬λ§·ν νμ¬ λ°ν | |
return f"Label: {result[0]['label']}, Score: {result[0]['score']:.2f}" | |
# Gradio μΈν°νμ΄μ€ μ€μ | |
iface = gr.Interface(fn=get_sentiment, title="Sentiment Analysis", inputs="text", outputs="text") | |
# μΈν°νμ΄μ€ μ€ν | |
iface.launch() |