Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -20,7 +20,24 @@ from PIL import Image
|
|
| 20 |
from gradio_client import Client
|
| 21 |
import time
|
| 22 |
|
| 23 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|