ginipick commited on
Commit
7a610d2
Β·
verified Β·
1 Parent(s): b828d78

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -27
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: str,
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
- uploaded_content = read_uploaded_file(uploaded_file.name)
1284
- print(f"[파일 μ—…λ‘œλ“œ] λ‚΄μš© 길이: {len(uploaded_content)}자")
 
 
 
 
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="🎯 Open GAMMA - AI PPT Generator 'GamJa'", theme=gr.themes.Soft(), css="""
1422
  .preview-container { max-width: 1400px; margin: 0 auto; }
1423
  """) as demo:
1424
  gr.Markdown("""
1425
- # 🎯 AI automatically creates premium presentations with storytelling, 3D visuals and diagrams. Base LLM: 'gemma-3-R1984-27B' @ Powered by VIDraft
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.r:02x}{rgb_color.g:02x}{rgb_color.b:02x}"
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 template, slide_count, theme: (
1697
- update_template_info(template, slide_count),
1698
- update_theme_preview(theme)
1699
  ),
1700
- inputs=[template_select, slide_count, theme_select],
1701
  outputs=[template_info, theme_preview]
1702
  )
1703
 
@@ -1725,4 +1716,5 @@ if __name__ == "__main__":
1725
 
1726
  print("="*50 + "\n")
1727
 
1728
- demo.launch()
 
 
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)