Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,17 +7,6 @@ model = AutoModelForSequenceClassification.from_pretrained(model_name)
|
|
| 7 |
|
| 8 |
classifier = pipeline("text-classification", model=model, tokenizer=tokenizer)
|
| 9 |
|
| 10 |
-
# # ์ถ๋ก ํ์ดํ๋ผ์ธ ์ค์
|
| 11 |
-
# inference_pipeline = pipeline(
|
| 12 |
-
# "text-classification",
|
| 13 |
-
# model=model,
|
| 14 |
-
# tokenizer=tokenizer,
|
| 15 |
-
# return_all_scores=True,
|
| 16 |
-
# )
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
def classify_text(text):
|
| 22 |
"""
|
| 23 |
์ฃผ์ด์ง ํ
์คํธ๊ฐ ๋ถ์ ์ ํ์ง ์ฌ๋ถ๋ฅผ ํ๋ณํฉ๋๋ค.
|
|
@@ -34,17 +23,26 @@ def classify_text(text):
|
|
| 34 |
for result in results:
|
| 35 |
# ๋ชจ๋ธ์ ๋ฐ๋ผ ๋ผ๋ฒจ์ด ๋ค๋ฅผ ์ ์์ต๋๋ค.
|
| 36 |
if result['label'] == '์
ํ/์์ค' and result['score'] > 0.5:
|
| 37 |
-
return "
|
| 38 |
elif result['label'] == '์ฌ์ฑ/๊ฐ์กฑ' and result['score'] > 0.5:
|
| 39 |
-
return "
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
return "์ ์ ํ ๋ด์ฉ์
๋๋ค."
|
| 43 |
|
| 44 |
-
# def greet(name):
|
| 45 |
-
# return "Hello ๊ณฝ์ ์ " + name + "!!"
|
| 46 |
|
| 47 |
-
# results = inference_pipeline(example_sentence)
|
| 48 |
|
| 49 |
-
demo = gr.Interface(fn=classify_text, inputs="textbox", title="๋ถ์ ์ ๋ฌธ์ฅ ๊ฒ์ถ๊ธฐ", theme="soft", description="๊ธฐ์ค:
|
| 50 |
-
demo.launch()
|
|
|
|
|
|
| 7 |
|
| 8 |
classifier = pipeline("text-classification", model=model, tokenizer=tokenizer)
|
| 9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
def classify_text(text):
|
| 11 |
"""
|
| 12 |
์ฃผ์ด์ง ํ
์คํธ๊ฐ ๋ถ์ ์ ํ์ง ์ฌ๋ถ๋ฅผ ํ๋ณํฉ๋๋ค.
|
|
|
|
| 23 |
for result in results:
|
| 24 |
# ๋ชจ๋ธ์ ๋ฐ๋ผ ๋ผ๋ฒจ์ด ๋ค๋ฅผ ์ ์์ต๋๋ค.
|
| 25 |
if result['label'] == '์
ํ/์์ค' and result['score'] > 0.5:
|
| 26 |
+
return "์
ํ/์์ค์
๋๋ค."
|
| 27 |
elif result['label'] == '์ฌ์ฑ/๊ฐ์กฑ' and result['score'] > 0.5:
|
| 28 |
+
return "์ฌ์ฑ ํ์ค์
๋๋ค"
|
| 29 |
+
elif result['label'] == '๋จ์ฑ' and result['score'] > 0.5:
|
| 30 |
+
return "๋จ์ฑ ํ์ค์
๋๋ค"
|
| 31 |
+
elif result['label'] == '์ธ์ข
/๊ตญ์ ' and result['score'] > 0.5:
|
| 32 |
+
return "์ธ์ข
/๊ตญ์ ํ์ค์
๋๋ค"
|
| 33 |
+
elif result['label'] == '์ฐ๋ น' and result['score'] > 0.5:
|
| 34 |
+
return "์ฐ๋ น ํ์ค์
๋๋ค"
|
| 35 |
+
elif result['label'] == '์ง์ญ' and result['score'] > 0.5:
|
| 36 |
+
return "์ง์ญ ํ์ค์
๋๋ค"
|
| 37 |
+
elif result['label'] == '์ข
๊ต' and result['score'] > 0.5:
|
| 38 |
+
return "์ข
๊ต ํ์ค์
๋๋ค"
|
| 39 |
+
elif result['label'] == '๊ธฐํ ํ์ค' and result['score'] > 0.5:
|
| 40 |
+
return "๊ธฐํ ํ์ค์
๋๋ค"
|
| 41 |
|
| 42 |
return "์ ์ ํ ๋ด์ฉ์
๋๋ค."
|
| 43 |
|
|
|
|
|
|
|
| 44 |
|
|
|
|
| 45 |
|
| 46 |
+
demo = gr.Interface(fn=classify_text, inputs="textbox", title="๋ถ์ ์ ๋ฌธ์ฅ ๊ฒ์ถ๊ธฐ", theme="soft", description="๊ธฐ์ค: ์ฌ์ฑ/๊ฐ์กฑ, ๋จ์ฑ, ์ฑ์์์, ์ธ์ข
/๊ตญ์ , ์ฐ๋ น, ์ง์ญ, ์ข
๊ต, ๊ธฐํ ํ์ค, ์
ํ/์์ค, outputs="textbox")
|
| 47 |
+
demo.launch()
|
| 48 |
+
|