openfree commited on
Commit
c35ece1
·
verified ·
1 Parent(s): ac8b335

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+ classifier = pipeline("zero-shot-classification", model="facebook/bart-large-mnli")
4
+ def classify_text(text, labels):
5
+ labels = [label.strip() for label in labels.split(",")]
6
+ result = classifier(text, labels)
7
+ return {label: float(score) for label, score in zip(result['labels'], result['scores'])}
8
+ demo = gr.Interface(
9
+ fn=classify_text,
10
+ inputs=[
11
+ gr.Textbox(label="분류할 텍스트를 입력하세요", placeholder="텍스트를 입력하세요..."),
12
+ gr.Textbox(label="레이블 목록 (쉼표로 구분)", placeholder="긍정,부정,중립", value="긍정,부정,중립")
13
+ ],
14
+ outputs=gr.Label(label="분류 결과"),
15
+ title="텍스트 분류기",
16
+ theme="soft",
17
+ examples=[
18
+ ["오늘은 날씨가 너무 좋아서 기분이 좋아요!", "긍정,부정,중립"],
19
+ ["이 영화는 정말 실망스러웠습니다.", "긍정,부정,중립"],
20
+ ["오늘 점심으로 뭘 먹을지 고민이네요.", "긍정,부정,중립"]
21
+ ]
22
+ )
23
+
24
+ if __name__ == '__main__':
25
+ demo.launch()