Update app.py
Browse files
app.py
CHANGED
@@ -3,12 +3,9 @@ import replicate
|
|
3 |
import requests
|
4 |
import os
|
5 |
import json
|
6 |
-
import asyncio
|
7 |
-
import concurrent.futures
|
8 |
from io import BytesIO
|
9 |
from PIL import Image
|
10 |
from typing import List, Tuple, Dict
|
11 |
-
import zipfile
|
12 |
from datetime import datetime
|
13 |
import time
|
14 |
import traceback
|
@@ -995,7 +992,6 @@ def create_pptx_file(results: List[Dict], topic: str, template_name: str, theme_
|
|
995 |
title_bg.fill.solid()
|
996 |
title_bg.fill.fore_color.rgb = RGBColor(0, 0, 0)
|
997 |
title_bg.fill.transparency = 0.5
|
998 |
-
title_bg.adjustments[0] = 0.1
|
999 |
title_bg.line.fill.background()
|
1000 |
|
1001 |
# μ λͺ© ν
μ€νΈ μΆκ°
|
@@ -1054,7 +1050,6 @@ def create_pptx_file(results: List[Dict], topic: str, template_name: str, theme_
|
|
1054 |
thanks_bg.fill.solid()
|
1055 |
thanks_bg.fill.fore_color.rgb = RGBColor(0, 0, 0)
|
1056 |
thanks_bg.fill.transparency = 0.5
|
1057 |
-
thanks_bg.adjustments[0] = 0.1
|
1058 |
thanks_bg.line.fill.background()
|
1059 |
|
1060 |
# Thank You ν
μ€νΈ
|
@@ -1088,9 +1083,6 @@ def create_pptx_file(results: List[Dict], topic: str, template_name: str, theme_
|
|
1088 |
title_box_bg.fill.fore_color.rgb = theme["box_fill"]
|
1089 |
title_box_bg.fill.transparency = 1 - theme["box_opacity"]
|
1090 |
|
1091 |
-
# λ₯κ·Ό μ λ μ‘°μ
|
1092 |
-
title_box_bg.adjustments[0] = 0.15 # λ₯κ·Ό μ λ (0-1)
|
1093 |
-
|
1094 |
# κ·Έλ¦Όμ ν¨κ³Ό
|
1095 |
if theme["shadow"]:
|
1096 |
shadow = title_box_bg.shadow
|
@@ -1125,9 +1117,6 @@ def create_pptx_file(results: List[Dict], topic: str, template_name: str, theme_
|
|
1125 |
text_box_bg.fill.fore_color.rgb = theme["box_fill"]
|
1126 |
text_box_bg.fill.transparency = 1 - theme["box_opacity"]
|
1127 |
|
1128 |
-
# λ₯κ·Ό μ λ μ‘°μ
|
1129 |
-
text_box_bg.adjustments[0] = 0.12
|
1130 |
-
|
1131 |
if theme["shadow"]:
|
1132 |
shadow = text_box_bg.shadow
|
1133 |
shadow.visible = True
|
@@ -1179,9 +1168,6 @@ def create_pptx_file(results: List[Dict], topic: str, template_name: str, theme_
|
|
1179 |
img_box_bg.fill.fore_color.rgb = RGBColor(248, 249, 250)
|
1180 |
img_box_bg.fill.transparency = 0.1
|
1181 |
|
1182 |
-
# λ₯κ·Ό μ λ μ‘°μ
|
1183 |
-
img_box_bg.adjustments[0] = 0.12
|
1184 |
-
|
1185 |
if theme["shadow"]:
|
1186 |
shadow = img_box_bg.shadow
|
1187 |
shadow.visible = True
|
@@ -1270,7 +1256,7 @@ def generate_dynamic_slides(topic: str, template: Dict, slide_count: int) -> Lis
|
|
1270 |
return slides
|
1271 |
|
1272 |
def generate_ppt_with_content(topic: str, template_name: str, custom_slides: List[Dict],
|
1273 |
-
slide_count: int, seed: int, uploaded_file
|
1274 |
use_web_search: bool, theme_name: str = "λ―Έλλ© λΌμ΄νΈ",
|
1275 |
progress=gr.Progress()):
|
1276 |
"""PPT μ΄λ―Έμ§μ ν
μ€νΈ λ΄μ©μ ν¨κ» μμ± (λ°νμ λ
ΈνΈ ν¬ν¨)"""
|
@@ -1279,9 +1265,13 @@ def generate_ppt_with_content(topic: str, template_name: str, custom_slides: Lis
|
|
1279 |
|
1280 |
# μ
λ‘λλ νμΌ λ΄μ© μ½κΈ°
|
1281 |
uploaded_content = ""
|
1282 |
-
if uploaded_file:
|
1283 |
-
|
1284 |
-
|
|
|
|
|
|
|
|
|
1285 |
|
1286 |
# ν
νλ¦Ώ μ ν λ° μ¬λΌμ΄λ ꡬμ±
|
1287 |
if template_name == "μ¬μ©μ μ μ" and custom_slides:
|
@@ -1418,11 +1408,11 @@ def create_custom_slides_ui():
|
|
1418 |
return slides
|
1419 |
|
1420 |
# Gradio μΈν°νμ΄μ€ μμ±
|
1421 |
-
with gr.Blocks(title="
|
1422 |
.preview-container { max-width: 1400px; margin: 0 auto; }
|
1423 |
""") as demo:
|
1424 |
gr.Markdown("""
|
1425 |
-
# π― AI
|
1426 |
|
1427 |
### ν
μ€νΈμ μ΄λ―Έμ§κ° μλ²½νκ² μ‘°νλ νλ μ ν
μ΄μ
μ μλμΌλ‘ μμ±νκ³ λ€μ΄λ‘λνμΈμ!
|
1428 |
|
@@ -1490,7 +1480,8 @@ with gr.Blocks(title="π― Open GAMMA - AI PPT Generator 'GamJa'", theme=gr.them
|
|
1490 |
file_upload = gr.File(
|
1491 |
label="μ°Έκ³ μλ£ μ
λ‘λ (μ ν)",
|
1492 |
file_types=[".pdf", ".csv", ".txt"],
|
1493 |
-
type="filepath"
|
|
|
1494 |
)
|
1495 |
|
1496 |
# μΉ κ²μ μ΅μ
|
@@ -1555,7 +1546,7 @@ with gr.Blocks(title="π― Open GAMMA - AI PPT Generator 'GamJa'", theme=gr.them
|
|
1555 |
|
1556 |
# RGB κ°μ hexλ‘ λ³ν
|
1557 |
def rgb_to_hex(rgb_color):
|
1558 |
-
return f"#{rgb_color
|
1559 |
|
1560 |
bg_hex = rgb_to_hex(theme["background"])
|
1561 |
box_hex = rgb_to_hex(theme["box_fill"])
|
@@ -1693,11 +1684,11 @@ with gr.Blocks(title="π― Open GAMMA - AI PPT Generator 'GamJa'", theme=gr.them
|
|
1693 |
|
1694 |
# μ΄κΈ° ν
νλ¦Ώ μ 보 νμ
|
1695 |
demo.load(
|
1696 |
-
fn=lambda
|
1697 |
-
update_template_info(
|
1698 |
-
update_theme_preview(
|
1699 |
),
|
1700 |
-
inputs=[
|
1701 |
outputs=[template_info, theme_preview]
|
1702 |
)
|
1703 |
|
@@ -1725,4 +1716,5 @@ if __name__ == "__main__":
|
|
1725 |
|
1726 |
print("="*50 + "\n")
|
1727 |
|
1728 |
-
|
|
|
|
3 |
import requests
|
4 |
import os
|
5 |
import json
|
|
|
|
|
6 |
from io import BytesIO
|
7 |
from PIL import Image
|
8 |
from typing import List, Tuple, Dict
|
|
|
9 |
from datetime import datetime
|
10 |
import time
|
11 |
import traceback
|
|
|
992 |
title_bg.fill.solid()
|
993 |
title_bg.fill.fore_color.rgb = RGBColor(0, 0, 0)
|
994 |
title_bg.fill.transparency = 0.5
|
|
|
995 |
title_bg.line.fill.background()
|
996 |
|
997 |
# μ λͺ© ν
μ€νΈ μΆκ°
|
|
|
1050 |
thanks_bg.fill.solid()
|
1051 |
thanks_bg.fill.fore_color.rgb = RGBColor(0, 0, 0)
|
1052 |
thanks_bg.fill.transparency = 0.5
|
|
|
1053 |
thanks_bg.line.fill.background()
|
1054 |
|
1055 |
# Thank You ν
μ€νΈ
|
|
|
1083 |
title_box_bg.fill.fore_color.rgb = theme["box_fill"]
|
1084 |
title_box_bg.fill.transparency = 1 - theme["box_opacity"]
|
1085 |
|
|
|
|
|
|
|
1086 |
# κ·Έλ¦Όμ ν¨κ³Ό
|
1087 |
if theme["shadow"]:
|
1088 |
shadow = title_box_bg.shadow
|
|
|
1117 |
text_box_bg.fill.fore_color.rgb = theme["box_fill"]
|
1118 |
text_box_bg.fill.transparency = 1 - theme["box_opacity"]
|
1119 |
|
|
|
|
|
|
|
1120 |
if theme["shadow"]:
|
1121 |
shadow = text_box_bg.shadow
|
1122 |
shadow.visible = True
|
|
|
1168 |
img_box_bg.fill.fore_color.rgb = RGBColor(248, 249, 250)
|
1169 |
img_box_bg.fill.transparency = 0.1
|
1170 |
|
|
|
|
|
|
|
1171 |
if theme["shadow"]:
|
1172 |
shadow = img_box_bg.shadow
|
1173 |
shadow.visible = True
|
|
|
1256 |
return slides
|
1257 |
|
1258 |
def generate_ppt_with_content(topic: str, template_name: str, custom_slides: List[Dict],
|
1259 |
+
slide_count: int, seed: int, uploaded_file,
|
1260 |
use_web_search: bool, theme_name: str = "λ―Έλλ© λΌμ΄νΈ",
|
1261 |
progress=gr.Progress()):
|
1262 |
"""PPT μ΄λ―Έμ§μ ν
μ€νΈ λ΄μ©μ ν¨κ» μμ± (λ°νμ λ
ΈνΈ ν¬ν¨)"""
|
|
|
1265 |
|
1266 |
# μ
λ‘λλ νμΌ λ΄μ© μ½κΈ°
|
1267 |
uploaded_content = ""
|
1268 |
+
if uploaded_file is not None:
|
1269 |
+
try:
|
1270 |
+
uploaded_content = read_uploaded_file(uploaded_file.name)
|
1271 |
+
print(f"[νμΌ μ
λ‘λ] λ΄μ© κΈΈμ΄: {len(uploaded_content)}μ")
|
1272 |
+
except Exception as e:
|
1273 |
+
print(f"[νμΌ μ
λ‘λ] μ€λ₯: {str(e)}")
|
1274 |
+
uploaded_content = ""
|
1275 |
|
1276 |
# ν
νλ¦Ώ μ ν λ° μ¬λΌμ΄λ ꡬμ±
|
1277 |
if template_name == "μ¬μ©μ μ μ" and custom_slides:
|
|
|
1408 |
return slides
|
1409 |
|
1410 |
# Gradio μΈν°νμ΄μ€ μμ±
|
1411 |
+
with gr.Blocks(title="PPT μ΄λ―Έμ§ μμ±κΈ°", theme=gr.themes.Soft(), css="""
|
1412 |
.preview-container { max-width: 1400px; margin: 0 auto; }
|
1413 |
""") as demo:
|
1414 |
gr.Markdown("""
|
1415 |
+
# π― AI κΈ°λ° PPT ν΅ν© μμ±κΈ° (λμμΈ ν
λ§ ν¬ν¨)
|
1416 |
|
1417 |
### ν
μ€νΈμ μ΄λ―Έμ§κ° μλ²½νκ² μ‘°νλ νλ μ ν
μ΄μ
μ μλμΌλ‘ μμ±νκ³ λ€μ΄λ‘λνμΈμ!
|
1418 |
|
|
|
1480 |
file_upload = gr.File(
|
1481 |
label="μ°Έκ³ μλ£ μ
λ‘λ (μ ν)",
|
1482 |
file_types=[".pdf", ".csv", ".txt"],
|
1483 |
+
type="filepath",
|
1484 |
+
value=None
|
1485 |
)
|
1486 |
|
1487 |
# μΉ κ²μ μ΅μ
|
|
|
1546 |
|
1547 |
# RGB κ°μ hexλ‘ λ³ν
|
1548 |
def rgb_to_hex(rgb_color):
|
1549 |
+
return f"#{rgb_color[0]:02x}{rgb_color[1]:02x}{rgb_color[2]:02x}"
|
1550 |
|
1551 |
bg_hex = rgb_to_hex(theme["background"])
|
1552 |
box_hex = rgb_to_hex(theme["box_fill"])
|
|
|
1684 |
|
1685 |
# μ΄κΈ° ν
νλ¦Ώ μ 보 νμ
|
1686 |
demo.load(
|
1687 |
+
fn=lambda: (
|
1688 |
+
update_template_info("λΉμ¦λμ€ μ μμ", 8),
|
1689 |
+
update_theme_preview("λ―Έλλ© λΌμ΄νΈ")
|
1690 |
),
|
1691 |
+
inputs=[],
|
1692 |
outputs=[template_info, theme_preview]
|
1693 |
)
|
1694 |
|
|
|
1716 |
|
1717 |
print("="*50 + "\n")
|
1718 |
|
1719 |
+
# SSR λͺ¨λ λΉνμ±ννμ¬ μ€ν
|
1720 |
+
demo.launch(ssr_mode=False)
|