Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,21 +1,26 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from transformers import
|
| 3 |
|
| 4 |
-
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
def summarize(text):
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
|
|
|
| 14 |
|
| 15 |
gr.Interface(
|
| 16 |
fn=summarize,
|
| 17 |
-
inputs=gr.Textbox(lines=
|
| 18 |
outputs="text",
|
| 19 |
-
title="CW
|
| 20 |
-
description="
|
| 21 |
).launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
|
| 4 |
+
print("๐ ์์ฝ๊ธฐ ๋ก๋ฉ ์ค...")
|
| 5 |
|
| 6 |
+
summarizer = pipeline(
|
| 7 |
+
"summarization",
|
| 8 |
+
model="facebook/bart-large-cnn"
|
| 9 |
+
)
|
| 10 |
+
|
| 11 |
+
print("โ
๋ชจ๋ธ ๋ก๋ฉ ์๋ฃ")
|
| 12 |
|
| 13 |
def summarize(text):
|
| 14 |
+
try:
|
| 15 |
+
result = summarizer(text, max_length=150, min_length=40, do_sample=False)
|
| 16 |
+
return result[0]["summary_text"]
|
| 17 |
+
except Exception as e:
|
| 18 |
+
return f"โ ์์ฝ ์คํจ: {e}"
|
| 19 |
|
| 20 |
gr.Interface(
|
| 21 |
fn=summarize,
|
| 22 |
+
inputs=gr.Textbox(lines=10, placeholder="์์ฝํ ํ
์คํธ๋ฅผ ์
๋ ฅํ์ธ์"),
|
| 23 |
outputs="text",
|
| 24 |
+
title="CW ์์ฝ ๋น์ - BART ๋ชจ๋ธ",
|
| 25 |
+
description="facebook/bart-large-cnn ๊ธฐ๋ฐ ๋ด์ค/๋ฌธ์ ์์ฝ๊ธฐ"
|
| 26 |
).launch()
|