openfree commited on
Commit
bdbdfe3
ยท
verified ยท
1 Parent(s): 35b3df6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -4
app.py CHANGED
@@ -20,7 +20,24 @@ from PIL import Image
20
  from gradio_client import Client
21
  import time
22
 
23
- # python-pptx ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ํ™•์ธ
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  try:
25
  from pptx import Presentation
26
  from pptx.util import Inches, Pt
@@ -34,7 +51,7 @@ except ImportError:
34
  PPTX_AVAILABLE = False
35
  logger.warning("python-pptx ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๊ฐ€ ์„ค์น˜๋˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค. pip install python-pptx")
36
 
37
- # ๋‹ค์ด์–ด๊ทธ๋žจ ์ƒ์„ฑ๊ธฐ ๋ชจ๋“ˆ import ์ถ”๊ฐ€
38
  try:
39
  from concept_map_generator import generate_concept_map
40
  from synoptic_chart_generator import generate_synoptic_chart
@@ -47,10 +64,15 @@ except ImportError as e:
47
  DIAGRAM_GENERATORS_AVAILABLE = False
48
  logger.warning(f"๋‹ค์ด์–ด๊ทธ๋žจ ์ƒ์„ฑ๊ธฐ ๋ชจ๋“ˆ์„ ์ฐพ์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค: {e}")
49
 
50
- # ํ•œ๊ธ€ ํฐํŠธ ๊ฒฝ๋กœ ์„ค์ •
51
  KOREAN_FONT_PATH = os.path.join(os.path.dirname(__file__), "NanumGothic-Regular.ttf")
52
  if not os.path.exists(KOREAN_FONT_PATH):
53
- logger.warning(f"ํ•œ๊ธ€ ํฐํŠธ ํŒŒ์ผ์„ ์ฐพ์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค: {KOREAN_FONT_PATH}")
 
 
 
 
 
54
 
55
  ##############################################################################
56
  # API Configuration
 
20
  from gradio_client import Client
21
  import time
22
 
23
+ # โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ ํ•œ๊ธ€โ€†/โ€†ํฐํŠธ ์„ค์ • โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
24
+ import matplotlib as mpl
25
+ import matplotlib.font_manager as fm
26
+ import subprocess
27
+
28
+ NANUM_PATH = "/usr/share/fonts/truetype/nanum/NanumGothic.ttf" # ์‹œ์Šคํ…œ ์„ค์น˜ ๊ฒฝ๋กœ
29
+
30
+ # matplotlib์šฉ ๊ธ€๊ผด ๋“ฑ๋ก
31
+ fm.fontManager.addfont(NANUM_PATH)
32
+ mpl.rcParams["font.family"] = "NanumGothic"
33
+
34
+ # Graphviz๊ฐ€ ์ฐพ์„ ์ˆ˜ ์žˆ๋„๋ก ํฐํŠธ ๊ฒฝ๋กœ ์ง€์ •
35
+ os.environ["GDFONTPATH"] = "/usr/share/fonts/truetype/nanum"
36
+
37
+ # ํฐํŠธ ์บ์‹œ ๊ฐ•์ œ ๊ฐฑ์‹ (ํ•œ ๋ฒˆ๋งŒ ์‹คํ–‰๋ผ๋„ ๋ฌด๋ฐฉ)
38
+ subprocess.run(["fc-cache", "-fv"])
39
+
40
+ # โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ PPTX & ๋‹ค์ด์–ด๊ทธ๋žจ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
41
  try:
42
  from pptx import Presentation
43
  from pptx.util import Inches, Pt
 
51
  PPTX_AVAILABLE = False
52
  logger.warning("python-pptx ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๊ฐ€ ์„ค์น˜๋˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค. pip install python-pptx")
53
 
54
+ # ๋‹ค์ด์–ด๊ทธ๋žจ ์ƒ์„ฑ๊ธฐ ๋ชจ๋“ˆ import
55
  try:
56
  from concept_map_generator import generate_concept_map
57
  from synoptic_chart_generator import generate_synoptic_chart
 
64
  DIAGRAM_GENERATORS_AVAILABLE = False
65
  logger.warning(f"๋‹ค์ด์–ด๊ทธ๋žจ ์ƒ์„ฑ๊ธฐ ๋ชจ๋“ˆ์„ ์ฐพ์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค: {e}")
66
 
67
+ # โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ ํ•œ๊ธ€ ํฐํŠธ ๊ฒฝ๋กœ ์„ค์ • (๋‹ค์ด์–ด๊ทธ๋žจ์šฉ) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
68
  KOREAN_FONT_PATH = os.path.join(os.path.dirname(__file__), "NanumGothic-Regular.ttf")
69
  if not os.path.exists(KOREAN_FONT_PATH):
70
+ # ๋กœ์ปฌ ํฐํŠธ๊ฐ€ ์—†์œผ๋ฉด ์‹œ์Šคํ…œ ์„ค์น˜ ๊ฒฝ๋กœ ์‚ฌ์šฉ
71
+ KOREAN_FONT_PATH = NANUM_PATH
72
+
73
+ # ๋‹ค๋ฅธ ๋ชจ๋“ˆ์—์„œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋„๋ก ํ™˜๊ฒฝ๋ณ€์ˆ˜ ๋“ฑ๋ก
74
+ os.environ["KOREAN_FONT_PATH"] = KOREAN_FONT_PATH
75
+
76
 
77
  ##############################################################################
78
  # API Configuration