Spaces:
Runtime error
Runtime error
update: add Notion link in description
Browse files
app.py
CHANGED
|
@@ -7,29 +7,14 @@ Original file is located at
|
|
| 7 |
https://colab.research.google.com/drive/1wnyeCNxzRVxoae3tCcMuf3s9Adx503U7
|
| 8 |
"""
|
| 9 |
|
| 10 |
-
# app.py
|
| 11 |
import gradio as gr
|
| 12 |
-
import
|
| 13 |
-
|
| 14 |
-
# 우리 분석 로직 불러오기
|
| 15 |
-
from news_analyzer import run_once, title_attention_index, load_models
|
| 16 |
-
|
| 17 |
-
# (선로드) 모델을 미리 로드해두면 첫 호출 지연이 줄어듭니다.
|
| 18 |
-
try:
|
| 19 |
-
load_models()
|
| 20 |
-
except Exception as e:
|
| 21 |
-
print("[WARN] warmup load_models failed:", e)
|
| 22 |
|
| 23 |
def predict(title, body):
|
| 24 |
-
"""
|
| 25 |
-
Gradio UI에서 호출되는 함수. news_analyzer.run_once()를 그대로 사용.
|
| 26 |
-
"""
|
| 27 |
r = run_once(title, body)
|
| 28 |
-
|
| 29 |
final_score = r["최종 기사 점수"]
|
| 30 |
grade = title_attention_index(final_score)
|
| 31 |
-
|
| 32 |
-
# UI에 보여줄 값들만 반환
|
| 33 |
return (
|
| 34 |
r["요약유사도"],
|
| 35 |
r["본문 일치도(Top5 평균)"],
|
|
@@ -41,8 +26,8 @@ def predict(title, body):
|
|
| 41 |
demo = gr.Interface(
|
| 42 |
fn=predict,
|
| 43 |
inputs=[
|
| 44 |
-
gr.Textbox(label="제목", lines=2
|
| 45 |
-
gr.Textbox(label="본문", lines=18, placeholder="기사 본문을 붙여넣으세요"),
|
| 46 |
],
|
| 47 |
outputs=[
|
| 48 |
gr.Number(label="요약유사도"),
|
|
@@ -52,10 +37,12 @@ demo = gr.Interface(
|
|
| 52 |
gr.Textbox(label="제목 주의 지수", interactive=False),
|
| 53 |
],
|
| 54 |
title="제목 주의 지수",
|
| 55 |
-
description=
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
)
|
| 57 |
|
| 58 |
-
# Spaces에서는 share/server_name 지정 불필요
|
| 59 |
if __name__ == "__main__":
|
| 60 |
-
#
|
| 61 |
-
demo.queue().launch()
|
|
|
|
| 7 |
https://colab.research.google.com/drive/1wnyeCNxzRVxoae3tCcMuf3s9Adx503U7
|
| 8 |
"""
|
| 9 |
|
| 10 |
+
# app.py
|
| 11 |
import gradio as gr
|
| 12 |
+
from news_analyzer import run_once, title_attention_index
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
def predict(title, body):
|
|
|
|
|
|
|
|
|
|
| 15 |
r = run_once(title, body)
|
|
|
|
| 16 |
final_score = r["최종 기사 점수"]
|
| 17 |
grade = title_attention_index(final_score)
|
|
|
|
|
|
|
| 18 |
return (
|
| 19 |
r["요약유사도"],
|
| 20 |
r["본문 일치도(Top5 평균)"],
|
|
|
|
| 26 |
demo = gr.Interface(
|
| 27 |
fn=predict,
|
| 28 |
inputs=[
|
| 29 |
+
gr.Textbox(label="제목", lines=2),
|
| 30 |
+
gr.Textbox(label="본문", lines=18, placeholder="여기에 기사 본문을 붙여넣으세요"),
|
| 31 |
],
|
| 32 |
outputs=[
|
| 33 |
gr.Number(label="요약유사도"),
|
|
|
|
| 37 |
gr.Textbox(label="제목 주의 지수", interactive=False),
|
| 38 |
],
|
| 39 |
title="제목 주의 지수",
|
| 40 |
+
description=(
|
| 41 |
+
"제목/본문을 입력하면 제목-본문 유사도, 과장 점수를 바탕으로 '제목 주의 지수'를 계산합니다.\n\n"
|
| 42 |
+
"ℹ️ **자세한 설명이 궁금하다면 "
|
| 43 |
+
"[여기를 클릭하세요](https://www.notion.so/25cb058cee088026badfcab340e9966d?source=copy_link)**"
|
| 44 |
+
),
|
| 45 |
)
|
| 46 |
|
|
|
|
| 47 |
if __name__ == "__main__":
|
| 48 |
+
demo.launch() # Spaces에서는 이 라인이 없어도 자동 실행됩니다.
|
|
|