Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
@@ -1,13 +1,15 @@
|
|
1 |
#!/usr/bin/env python3
|
2 |
# -*- coding: utf-8 -*-
|
3 |
"""
|
4 |
-
3D Flipbook Viewer (Gradio) β
|
5 |
μ΅μ’
μμ : 2025-05-18
|
|
|
|
|
|
|
|
|
|
|
6 |
"""
|
7 |
|
8 |
-
# ββββββββββββββββββββββββββββ
|
9 |
-
# κΈ°λ³Έ λͺ¨λ
|
10 |
-
# ββββββββββββββββββββββββββββ
|
11 |
import os
|
12 |
import shutil
|
13 |
import uuid
|
@@ -17,7 +19,6 @@ import traceback
|
|
17 |
from pathlib import Path
|
18 |
from typing import Optional, List, Dict
|
19 |
|
20 |
-
# μΈλΆ λΌμ΄λΈλ¬λ¦¬
|
21 |
import gradio as gr
|
22 |
from PIL import Image
|
23 |
import fitz # PyMuPDF
|
@@ -26,28 +27,28 @@ import fitz # PyMuPDF
|
|
26 |
# λ‘κΉ
μ€μ
|
27 |
# ββββββββββββββββββββββββββββ
|
28 |
logging.basicConfig(
|
29 |
-
level=logging.INFO,
|
30 |
format="%(asctime)s [%(levelname)s] %(message)s",
|
31 |
-
filename="app.log",
|
32 |
filemode="a",
|
33 |
)
|
34 |
logging.info("π Flipbook app started")
|
35 |
|
36 |
# ββββββββββββββββββββββββββββ
|
37 |
-
#
|
38 |
# ββββββββββββββββββββββββββββ
|
39 |
TEMP_DIR = "temp"
|
40 |
UPLOAD_DIR = os.path.join(TEMP_DIR, "uploads")
|
41 |
OUTPUT_DIR = os.path.join(TEMP_DIR, "output")
|
42 |
THUMBS_DIR = os.path.join(OUTPUT_DIR, "thumbs")
|
43 |
-
HTML_DIR = os.path.join("public", "flipbooks")
|
44 |
|
45 |
-
#
|
46 |
for d in [TEMP_DIR, UPLOAD_DIR, OUTPUT_DIR, THUMBS_DIR, HTML_DIR]:
|
47 |
os.makedirs(d, exist_ok=True)
|
48 |
|
49 |
# ββββββββββββββββββββββββββββ
|
50 |
-
# μ νΈ
|
51 |
# ββββββββββββββββββββββββββββ
|
52 |
def create_thumbnail(src: str, dst: str, size=(300, 300)) -> Optional[str]:
|
53 |
"""μλ³Έ μ΄λ―Έμ§λ₯Ό μΈλ€μΌλ‘ μ μ₯ (μ΄λ―Έμ§ μ΄κΈ° μ€ν¨ μ None 리ν΄)"""
|
@@ -61,10 +62,10 @@ def create_thumbnail(src: str, dst: str, size=(300, 300)) -> Optional[str]:
|
|
61 |
return None
|
62 |
|
63 |
# ββββββββββββββββββββββββββββ
|
64 |
-
# PDF β μ΄λ―Έμ§
|
65 |
# ββββββββββββββββββββββββββββ
|
66 |
def process_pdf(pdf_path: str, session_id: str) -> List[Dict]:
|
67 |
-
"""PDF νμΌμ νμ΄μ§ λ³ PNGλ‘
|
68 |
pages_info = []
|
69 |
out_dir = os.path.join(OUTPUT_DIR, session_id)
|
70 |
th_dir = os.path.join(THUMBS_DIR, session_id)
|
@@ -74,7 +75,7 @@ def process_pdf(pdf_path: str, session_id: str) -> List[Dict]:
|
|
74 |
try:
|
75 |
pdf_doc = fitz.open(pdf_path)
|
76 |
for idx, page in enumerate(pdf_doc):
|
77 |
-
# ν΄μλ
|
78 |
mat = fitz.Matrix(1.5, 1.5)
|
79 |
pix = page.get_pixmap(matrix=mat)
|
80 |
img_path = os.path.join(out_dir, f"page_{idx+1}.png")
|
@@ -83,7 +84,7 @@ def process_pdf(pdf_path: str, session_id: str) -> List[Dict]:
|
|
83 |
thumb_path = os.path.join(th_dir, f"thumb_{idx+1}.png")
|
84 |
create_thumbnail(img_path, thumb_path)
|
85 |
|
86 |
-
# 첫
|
87 |
html_overlay = (
|
88 |
"""
|
89 |
<div style="position:absolute;top:50px;left:50px;
|
@@ -116,10 +117,10 @@ def process_pdf(pdf_path: str, session_id: str) -> List[Dict]:
|
|
116 |
return []
|
117 |
|
118 |
# ββββββββββββββββββββββββββββ
|
119 |
-
# μ΄λ―Έμ§
|
120 |
# ββββββββββββββββββββββββββββ
|
121 |
def process_images(img_paths: List[str], session_id: str) -> List[Dict]:
|
122 |
-
"""
|
123 |
pages_info = []
|
124 |
out_dir = os.path.join(OUTPUT_DIR, session_id)
|
125 |
th_dir = os.path.join(THUMBS_DIR, session_id)
|
@@ -134,7 +135,7 @@ def process_images(img_paths: List[str], session_id: str) -> List[Dict]:
|
|
134 |
thumb = os.path.join(th_dir, f"thumb_{i+1}.png")
|
135 |
create_thumbnail(dst, thumb)
|
136 |
|
137 |
-
# νμ΄μ§λ³
|
138 |
if i == 0:
|
139 |
html_overlay = """
|
140 |
<div style="position:absolute;top:50px;left:50px;
|
@@ -188,8 +189,11 @@ def generate_flipbook_html(
|
|
188 |
view_mode: str,
|
189 |
skin: str
|
190 |
) -> str:
|
191 |
-
"""
|
192 |
-
|
|
|
|
|
|
|
193 |
for p in pages_info:
|
194 |
if p.get("htmlContent") is None:
|
195 |
p.pop("htmlContent", None)
|
@@ -198,7 +202,6 @@ def generate_flipbook_html(
|
|
198 |
html_file = f"flipbook_{session_id}.html"
|
199 |
html_path = os.path.join(HTML_DIR, html_file)
|
200 |
|
201 |
-
# f-string λ΄λΆμμ JSμ© { }λ₯Ό νννλ €λ©΄ {{ }} λ‘ μ¨μΌ ν¨
|
202 |
html = f"""
|
203 |
<!DOCTYPE html>
|
204 |
<html lang="ko">
|
@@ -232,7 +235,6 @@ def generate_flipbook_html(
|
|
232 |
|
233 |
<script>
|
234 |
document.addEventListener('DOMContentLoaded', () => {{
|
235 |
-
// hide() ν¨μ: λ‘λ© λ©μμ§ μ κ±°
|
236 |
const hide = () => {{
|
237 |
document.getElementById('loading').style.display = 'none';
|
238 |
}};
|
@@ -270,6 +272,7 @@ document.addEventListener('DOMContentLoaded', () => {{
|
|
270 |
Path(html_path).write_text(html, encoding="utf-8")
|
271 |
public_url = f"/public/flipbooks/{html_file}"
|
272 |
|
|
|
273 |
return f"""
|
274 |
<div style="text-align:center;padding:20px;background:#f9f9f9;border-radius:5px">
|
275 |
<h2 style="margin:0;color:#333">ν립λΆμ΄ μ€λΉλμμ΅λλ€!</h2>
|
@@ -283,7 +286,7 @@ document.addEventListener('DOMContentLoaded', () => {{
|
|
283 |
"""
|
284 |
|
285 |
# ββββββββββββββββββββββββββββ
|
286 |
-
#
|
287 |
# ββββββββββββββββββββββββββββ
|
288 |
def create_flipbook_from_pdf(
|
289 |
pdf_file: Optional[gr.File],
|
@@ -300,24 +303,24 @@ def create_flipbook_from_pdf(
|
|
300 |
)
|
301 |
|
302 |
try:
|
303 |
-
# Gradio
|
304 |
uploaded_temp_path = pdf_file.name
|
305 |
|
306 |
-
#
|
307 |
filename_only = os.path.basename(uploaded_temp_path)
|
308 |
pdf_path = os.path.join(UPLOAD_DIR, filename_only)
|
309 |
shutil.copyfile(uploaded_temp_path, pdf_path)
|
310 |
|
311 |
debug.append(f"Copied PDF to: {pdf_path}")
|
312 |
|
313 |
-
# PDF
|
314 |
pages_info = process_pdf(pdf_path, session_id)
|
315 |
debug.append(f"Extracted pages: {len(pages_info)}")
|
316 |
|
317 |
if not pages_info:
|
318 |
raise RuntimeError("PDF μ²λ¦¬ κ²°κ³Όκ° λΉμ΄ μμ΅λλ€.")
|
319 |
|
320 |
-
# νλ¦½λΆ HTML
|
321 |
html_block = generate_flipbook_html(pages_info, session_id, view_mode, skin)
|
322 |
return html_block, "\n".join(debug)
|
323 |
|
@@ -331,7 +334,7 @@ def create_flipbook_from_pdf(
|
|
331 |
)
|
332 |
|
333 |
# ββββββββββββββββββββββββββββ
|
334 |
-
#
|
335 |
# ββββββββββββββββββββββββββββ
|
336 |
def create_flipbook_from_images(
|
337 |
images: Optional[List[gr.File]],
|
@@ -348,10 +351,9 @@ def create_flipbook_from_images(
|
|
348 |
)
|
349 |
|
350 |
try:
|
351 |
-
#
|
352 |
img_paths = []
|
353 |
for fobj in images:
|
354 |
-
# μμ νκ² temp ν΄λμ 볡μ¬
|
355 |
uploaded_temp_path = fobj.name
|
356 |
filename_only = os.path.basename(uploaded_temp_path)
|
357 |
local_img_path = os.path.join(UPLOAD_DIR, filename_only)
|
@@ -360,14 +362,14 @@ def create_flipbook_from_images(
|
|
360 |
|
361 |
debug.append(f"Images: {img_paths}")
|
362 |
|
363 |
-
# μ΄λ―Έμ§
|
364 |
pages_info = process_images(img_paths, session_id)
|
365 |
debug.append(f"Processed: {len(pages_info)}")
|
366 |
|
367 |
if not pages_info:
|
368 |
raise RuntimeError("μ΄λ―Έμ§ μ²λ¦¬ μ€ν¨")
|
369 |
|
370 |
-
# νλ¦½λΆ HTML
|
371 |
html_block = generate_flipbook_html(pages_info, session_id, view_mode, skin)
|
372 |
return html_block, "\n".join(debug)
|
373 |
|
@@ -391,16 +393,8 @@ with gr.Blocks(title="3D Flipbook Viewer") as demo:
|
|
391 |
with gr.TabItem("PDF μ
λ‘λ"):
|
392 |
pdf_file = gr.File(label="PDF νμΌ", file_types=[".pdf"])
|
393 |
with gr.Accordion("κ³ κΈ μ€μ ", open=False):
|
394 |
-
pdf_view = gr.Radio(
|
395 |
-
|
396 |
-
value="2d",
|
397 |
-
label="λ·° λͺ¨λ",
|
398 |
-
)
|
399 |
-
pdf_skin = gr.Radio(
|
400 |
-
["light", "dark", "gradient"],
|
401 |
-
value="light",
|
402 |
-
label="μ€οΏ½οΏ½",
|
403 |
-
)
|
404 |
pdf_btn = gr.Button("PDF β ν립λΆ", variant="primary")
|
405 |
pdf_out = gr.HTML()
|
406 |
pdf_dbg = gr.Textbox(label="λλ²κ·Έ", lines=10)
|
@@ -413,22 +407,10 @@ with gr.Blocks(title="3D Flipbook Viewer") as demo:
|
|
413 |
|
414 |
# μ΄λ―Έμ§ ν
|
415 |
with gr.TabItem("μ΄λ―Έμ§ μ
λ‘λ"):
|
416 |
-
imgs = gr.File(
|
417 |
-
label="μ΄λ―Έμ§ νμΌλ€",
|
418 |
-
file_types=["image"],
|
419 |
-
file_count="multiple",
|
420 |
-
)
|
421 |
with gr.Accordion("κ³ κΈ μ€μ ", open=False):
|
422 |
-
img_view = gr.Radio(
|
423 |
-
|
424 |
-
value="2d",
|
425 |
-
label="λ·° λͺ¨λ",
|
426 |
-
)
|
427 |
-
img_skin = gr.Radio(
|
428 |
-
["light", "dark", "gradient"],
|
429 |
-
value="light",
|
430 |
-
label="μ€ν¨",
|
431 |
-
)
|
432 |
img_btn = gr.Button("μ΄λ―Έμ§ β ν립λΆ", variant="primary")
|
433 |
img_out = gr.HTML()
|
434 |
img_dbg = gr.Textbox(label="λλ²κ·Έ", lines=10)
|
@@ -450,5 +432,5 @@ with gr.Blocks(title="3D Flipbook Viewer") as demo:
|
|
450 |
# μ€ν
|
451 |
# ββββββββββββββββββββββββββββ
|
452 |
if __name__ == "__main__":
|
453 |
-
#
|
454 |
demo.launch(debug=True)
|
|
|
1 |
#!/usr/bin/env python3
|
2 |
# -*- coding: utf-8 -*-
|
3 |
"""
|
4 |
+
3D Flipbook Viewer (Gradio) β μ΅μ’
μμ λ²μ
|
5 |
μ΅μ’
μμ : 2025-05-18
|
6 |
+
|
7 |
+
- f-string ꡬ문μμ JSμ { }λ₯Ό {{ }}λ‘ μ΄μ€μΌμ΄ν μ²λ¦¬
|
8 |
+
- Python 3.9 μ΄ν νΈν(typing.Optional, typing.List)
|
9 |
+
- Gradioκ° μμ±ν μμ νμΌ β temp/uploads ν΄λλ‘ λ³΅μ¬ ν μ²λ¦¬
|
10 |
+
- /public ν΄λμ μ΅μ’
HTML μμ± (μ μ μλΉ λ³λ μ€μ νμ)
|
11 |
"""
|
12 |
|
|
|
|
|
|
|
13 |
import os
|
14 |
import shutil
|
15 |
import uuid
|
|
|
19 |
from pathlib import Path
|
20 |
from typing import Optional, List, Dict
|
21 |
|
|
|
22 |
import gradio as gr
|
23 |
from PIL import Image
|
24 |
import fitz # PyMuPDF
|
|
|
27 |
# λ‘κΉ
μ€μ
|
28 |
# ββββββββββββββββββββββββββββ
|
29 |
logging.basicConfig(
|
30 |
+
level=logging.INFO,
|
31 |
format="%(asctime)s [%(levelname)s] %(message)s",
|
32 |
+
filename="app.log",
|
33 |
filemode="a",
|
34 |
)
|
35 |
logging.info("π Flipbook app started")
|
36 |
|
37 |
# ββββββββββββββββββββββββββββ
|
38 |
+
# ν΄λ κ²½λ‘ μ€μ
|
39 |
# ββββββββββββββββββββββββββββ
|
40 |
TEMP_DIR = "temp"
|
41 |
UPLOAD_DIR = os.path.join(TEMP_DIR, "uploads")
|
42 |
OUTPUT_DIR = os.path.join(TEMP_DIR, "output")
|
43 |
THUMBS_DIR = os.path.join(OUTPUT_DIR, "thumbs")
|
44 |
+
HTML_DIR = os.path.join("public", "flipbooks")
|
45 |
|
46 |
+
# ν΄λ μμ±
|
47 |
for d in [TEMP_DIR, UPLOAD_DIR, OUTPUT_DIR, THUMBS_DIR, HTML_DIR]:
|
48 |
os.makedirs(d, exist_ok=True)
|
49 |
|
50 |
# ββββββββββββββββββββββββββββ
|
51 |
+
# μ νΈ ν¨μ: μ΄λ―Έμ§ μΈλ€μΌ
|
52 |
# ββββββββββββββββββββββββββββ
|
53 |
def create_thumbnail(src: str, dst: str, size=(300, 300)) -> Optional[str]:
|
54 |
"""μλ³Έ μ΄λ―Έμ§λ₯Ό μΈλ€μΌλ‘ μ μ₯ (μ΄λ―Έμ§ μ΄κΈ° μ€ν¨ μ None 리ν΄)"""
|
|
|
62 |
return None
|
63 |
|
64 |
# ββββββββββββββββββββββββββββ
|
65 |
+
# PDF μ²λ¦¬ ν¨μ: PDF β μ΄λ―Έμ§
|
66 |
# ββββββββββββββββββββββββββββ
|
67 |
def process_pdf(pdf_path: str, session_id: str) -> List[Dict]:
|
68 |
+
"""PDF νμΌμ νμ΄μ§ λ³ PNGλ‘ λ³ννκ³ , νμ΄μ§ μ 보 리μ€νΈ λ°ν"""
|
69 |
pages_info = []
|
70 |
out_dir = os.path.join(OUTPUT_DIR, session_id)
|
71 |
th_dir = os.path.join(THUMBS_DIR, session_id)
|
|
|
75 |
try:
|
76 |
pdf_doc = fitz.open(pdf_path)
|
77 |
for idx, page in enumerate(pdf_doc):
|
78 |
+
# ν΄μλ(1.5λ°° μ λ) - νμμ μ‘°μ
|
79 |
mat = fitz.Matrix(1.5, 1.5)
|
80 |
pix = page.get_pixmap(matrix=mat)
|
81 |
img_path = os.path.join(out_dir, f"page_{idx+1}.png")
|
|
|
84 |
thumb_path = os.path.join(th_dir, f"thumb_{idx+1}.png")
|
85 |
create_thumbnail(img_path, thumb_path)
|
86 |
|
87 |
+
# 첫 νμ΄μ§ μμλ‘ μ€λ²λ μ΄ HTML
|
88 |
html_overlay = (
|
89 |
"""
|
90 |
<div style="position:absolute;top:50px;left:50px;
|
|
|
117 |
return []
|
118 |
|
119 |
# ββββββββββββββββββββββββββββ
|
120 |
+
# μ΄λ―Έμ§ μ²λ¦¬ ν¨μ
|
121 |
# ββββββββββββββββββββββββββββ
|
122 |
def process_images(img_paths: List[str], session_id: str) -> List[Dict]:
|
123 |
+
"""μ΄λ―Έμ§λ€μ temp/outputμΌλ‘ 볡μ¬, μΈλ€μΌ μμ±, νμ΄μ§ μ 보 λ°ν"""
|
124 |
pages_info = []
|
125 |
out_dir = os.path.join(OUTPUT_DIR, session_id)
|
126 |
th_dir = os.path.join(THUMBS_DIR, session_id)
|
|
|
135 |
thumb = os.path.join(th_dir, f"thumb_{i+1}.png")
|
136 |
create_thumbnail(dst, thumb)
|
137 |
|
138 |
+
# νμ΄μ§λ³ μ€λ²λ μ΄ μμ
|
139 |
if i == 0:
|
140 |
html_overlay = """
|
141 |
<div style="position:absolute;top:50px;left:50px;
|
|
|
189 |
view_mode: str,
|
190 |
skin: str
|
191 |
) -> str:
|
192 |
+
"""
|
193 |
+
3D Flipbook μ© HTML νμΌ μμ± ν, HTML λ§ν¬(λ²νΌ) λΈλ‘μ λ°ν
|
194 |
+
- f-string μμμ JSμ { }λ {{ }}λ‘ μ΄μ€μΌμ΄ν
|
195 |
+
"""
|
196 |
+
# htmlContent=None μ κ±°
|
197 |
for p in pages_info:
|
198 |
if p.get("htmlContent") is None:
|
199 |
p.pop("htmlContent", None)
|
|
|
202 |
html_file = f"flipbook_{session_id}.html"
|
203 |
html_path = os.path.join(HTML_DIR, html_file)
|
204 |
|
|
|
205 |
html = f"""
|
206 |
<!DOCTYPE html>
|
207 |
<html lang="ko">
|
|
|
235 |
|
236 |
<script>
|
237 |
document.addEventListener('DOMContentLoaded', () => {{
|
|
|
238 |
const hide = () => {{
|
239 |
document.getElementById('loading').style.display = 'none';
|
240 |
}};
|
|
|
272 |
Path(html_path).write_text(html, encoding="utf-8")
|
273 |
public_url = f"/public/flipbooks/{html_file}"
|
274 |
|
275 |
+
# μ¬μ©μμκ² λλ €μ€ HTML λΈλ‘
|
276 |
return f"""
|
277 |
<div style="text-align:center;padding:20px;background:#f9f9f9;border-radius:5px">
|
278 |
<h2 style="margin:0;color:#333">ν립λΆμ΄ μ€λΉλμμ΅λλ€!</h2>
|
|
|
286 |
"""
|
287 |
|
288 |
# ββββββββββββββββββββββββββββ
|
289 |
+
# PDF μ
λ‘λ μ½λ°±
|
290 |
# ββββββββββββββββββββββββββββ
|
291 |
def create_flipbook_from_pdf(
|
292 |
pdf_file: Optional[gr.File],
|
|
|
303 |
)
|
304 |
|
305 |
try:
|
306 |
+
# Gradio μμ κ²½λ‘
|
307 |
uploaded_temp_path = pdf_file.name
|
308 |
|
309 |
+
# temp/uploads ν΄λμ 볡μ¬
|
310 |
filename_only = os.path.basename(uploaded_temp_path)
|
311 |
pdf_path = os.path.join(UPLOAD_DIR, filename_only)
|
312 |
shutil.copyfile(uploaded_temp_path, pdf_path)
|
313 |
|
314 |
debug.append(f"Copied PDF to: {pdf_path}")
|
315 |
|
316 |
+
# PDF μ²λ¦¬
|
317 |
pages_info = process_pdf(pdf_path, session_id)
|
318 |
debug.append(f"Extracted pages: {len(pages_info)}")
|
319 |
|
320 |
if not pages_info:
|
321 |
raise RuntimeError("PDF μ²λ¦¬ κ²°κ³Όκ° λΉμ΄ μμ΅λλ€.")
|
322 |
|
323 |
+
# νλ¦½λΆ HTML
|
324 |
html_block = generate_flipbook_html(pages_info, session_id, view_mode, skin)
|
325 |
return html_block, "\n".join(debug)
|
326 |
|
|
|
334 |
)
|
335 |
|
336 |
# ββββββββββββββββββββββββββββ
|
337 |
+
# μ΄λ―Έμ§ μ
λ‘λ μ½λ°±
|
338 |
# ββββββββββββββββββββββββββββ
|
339 |
def create_flipbook_from_images(
|
340 |
images: Optional[List[gr.File]],
|
|
|
351 |
)
|
352 |
|
353 |
try:
|
354 |
+
# μμ μ΄λ―Έμ§ κ²½λ‘λ€
|
355 |
img_paths = []
|
356 |
for fobj in images:
|
|
|
357 |
uploaded_temp_path = fobj.name
|
358 |
filename_only = os.path.basename(uploaded_temp_path)
|
359 |
local_img_path = os.path.join(UPLOAD_DIR, filename_only)
|
|
|
362 |
|
363 |
debug.append(f"Images: {img_paths}")
|
364 |
|
365 |
+
# μ΄λ―Έμ§ μ²λ¦¬
|
366 |
pages_info = process_images(img_paths, session_id)
|
367 |
debug.append(f"Processed: {len(pages_info)}")
|
368 |
|
369 |
if not pages_info:
|
370 |
raise RuntimeError("μ΄λ―Έμ§ μ²λ¦¬ μ€ν¨")
|
371 |
|
372 |
+
# νλ¦½λΆ HTML
|
373 |
html_block = generate_flipbook_html(pages_info, session_id, view_mode, skin)
|
374 |
return html_block, "\n".join(debug)
|
375 |
|
|
|
393 |
with gr.TabItem("PDF μ
λ‘λ"):
|
394 |
pdf_file = gr.File(label="PDF νμΌ", file_types=[".pdf"])
|
395 |
with gr.Accordion("κ³ κΈ μ€μ ", open=False):
|
396 |
+
pdf_view = gr.Radio(["webgl", "3d", "2d", "swipe"], value="2d", label="λ·° λͺ¨λ")
|
397 |
+
pdf_skin = gr.Radio(["light", "dark", "gradient"], value="light", label="μ€ν¨")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
398 |
pdf_btn = gr.Button("PDF β ν립λΆ", variant="primary")
|
399 |
pdf_out = gr.HTML()
|
400 |
pdf_dbg = gr.Textbox(label="λλ²κ·Έ", lines=10)
|
|
|
407 |
|
408 |
# μ΄λ―Έμ§ ν
|
409 |
with gr.TabItem("μ΄λ―Έμ§ μ
λ‘λ"):
|
410 |
+
imgs = gr.File(label="μ΄λ―Έμ§ νμΌλ€", file_types=["image"], file_count="multiple")
|
|
|
|
|
|
|
|
|
411 |
with gr.Accordion("κ³ κΈ μ€μ ", open=False):
|
412 |
+
img_view = gr.Radio(["webgl", "3d", "2d", "swipe"], value="2d", label="λ·° λͺ¨λ")
|
413 |
+
img_skin = gr.Radio(["light", "dark", "gradient"], value="light", label="μ€ν¨")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
414 |
img_btn = gr.Button("μ΄λ―Έμ§ β ν립λΆ", variant="primary")
|
415 |
img_out = gr.HTML()
|
416 |
img_dbg = gr.Textbox(label="λλ²κ·Έ", lines=10)
|
|
|
432 |
# μ€ν
|
433 |
# ββββββββββββββββββββββββββββ
|
434 |
if __name__ == "__main__":
|
435 |
+
# share=True λ± μ΅μ
μ λ£μ΄ λ°°ν¬/곡μ κ°λ₯
|
436 |
demo.launch(debug=True)
|