DSJA commited on
Commit
047b5ad
·
1 Parent(s): 98a0f6f

UI 폰트 수정 재시도

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -1,10 +1,14 @@
 
1
  import gradio as gr
2
  from news_analyzer import run_once, title_attention_index
3
  import math
4
 
5
-
6
  def convert_sim_to_text(score: float, threshold: float = 0.5) -> str:
7
-
 
 
 
8
  if score is None or (isinstance(score, float) and math.isnan(score)):
9
  return "판단 불가" # nan 값 처리
10
 
@@ -21,10 +25,11 @@ def predict(title, body):
21
  final_score = r["최종 기사 점수"]
22
  grade = title_attention_index(final_score)
23
 
 
24
  summary_sim_text = convert_sim_to_text(r["요약유사도"], threshold=0.45)
25
  body_sim_text = convert_sim_to_text(r["본문 일치도(Top5 평균)"], threshold=0.5)
26
 
27
- #
28
  return (
29
  grade, # [0] -> output_grade
30
  summary_sim_text, # [1] -> output_summary_sim
@@ -99,4 +104,4 @@ with gr.Blocks(css=CUSTOM_CSS, title="제목 주의 지수") as demo:
99
  clear_btn.click(lambda: [None, None] + [None] * len(outputs), outputs=inputs + outputs)
100
 
101
  if __name__ == "__main__":
102
- demo.launch()
 
1
+ # app.py
2
  import gradio as gr
3
  from news_analyzer import run_once, title_attention_index
4
  import math
5
 
6
+ # [NEW] ✨ 점수를 텍스트로 변환하는 헬퍼 함수
7
  def convert_sim_to_text(score: float, threshold: float = 0.5) -> str:
8
+ """
9
+ 유사도 점수를 기준으로 텍스트 등급을 반환합니다.
10
+ threshold (기본값 0.5) 이상이면 '유사', 미만이면 '유사하지 않음'으로 판단합니다.
11
+ """
12
  if score is None or (isinstance(score, float) and math.isnan(score)):
13
  return "판단 불가" # nan 값 처리
14
 
 
25
  final_score = r["최종 기사 점수"]
26
  grade = title_attention_index(final_score)
27
 
28
+ # [NEW] 텍스트 변환 로직을 predict 함수에 직접 추가
29
  summary_sim_text = convert_sim_to_text(r["요약유사도"], threshold=0.45)
30
  body_sim_text = convert_sim_to_text(r["본문 일치도(Top5 평균)"], threshold=0.5)
31
 
32
+ # [수정] return 순서를 outputs 순서와 정확히 일치시킵니다.
33
  return (
34
  grade, # [0] -> output_grade
35
  summary_sim_text, # [1] -> output_summary_sim
 
104
  clear_btn.click(lambda: [None, None] + [None] * len(outputs), outputs=inputs + outputs)
105
 
106
  if __name__ == "__main__":
107
+ demo.launch()