Update app.py
Browse files
app.py
CHANGED
@@ -546,8 +546,8 @@ def generate_images(blog_post):
|
|
546 |
lines = blog_post.split('\n')
|
547 |
title = lines[0].strip()
|
548 |
|
549 |
-
# 1.
|
550 |
-
title_prompt = f"
|
551 |
images.append(generate_image(title_prompt))
|
552 |
|
553 |
# ๋์
๋ถ์ ๋ณธ๋ฌธ, ๊ฒฐ๋ก ์ฐพ๊ธฐ
|
@@ -555,35 +555,35 @@ def generate_images(blog_post):
|
|
555 |
body_index = next((i for i, line in enumerate(lines) if '[๋ณธ๋ก 1]' in line), -1)
|
556 |
conclusion_index = next((i for i, line in enumerate(lines) if '[๊ฒฐ๋ก ]' in line), -1)
|
557 |
|
558 |
-
# 2.
|
559 |
if intro_index != -1 and body_index != -1:
|
560 |
intro_text = ' '.join(lines[intro_index+1:body_index])
|
561 |
-
intro_summary = f"
|
562 |
images.append(generate_image(intro_summary))
|
563 |
|
564 |
-
# 3. ๋ณธ๋ฌธ ์์ฝ์ผ๋ก ์ด๋ฏธ์ง ์์ฑ
|
565 |
if body_index != -1 and conclusion_index != -1:
|
566 |
body_text = ' '.join(lines[body_index+1:conclusion_index])
|
567 |
-
body_summary = f"
|
568 |
images.append(generate_image(body_summary))
|
569 |
|
570 |
-
# 4. ๊ฒฐ๋ก ์์ฝ์ผ๋ก
|
571 |
if conclusion_index != -1:
|
572 |
conclusion_text = ' '.join(lines[conclusion_index+1:])
|
573 |
-
|
574 |
-
images.append(generate_image(
|
575 |
|
576 |
-
# 5. ๊ฒฐ๋ก ์์ฝ์ผ๋ก
|
577 |
if conclusion_index != -1:
|
578 |
-
|
579 |
-
images.append(generate_image(
|
580 |
|
581 |
# ๋ง์ฝ ์์ฑ๋ ์ด๋ฏธ์ง๊ฐ 5๊ฐ ๋ฏธ๋ง์ด๋ผ๋ฉด, ๋ถ์กฑํ ๋งํผ ์๋ก์ด ์ด๋ฏธ์ง๋ฅผ ์์ฑ
|
582 |
while len(images) < 5:
|
583 |
-
random_prompt = f"
|
584 |
images.append(generate_image(random_prompt))
|
585 |
|
586 |
-
return images[:5] # ์ต๋ 5๊ฐ์ ์ด๋ฏธ์ง๋ง
|
587 |
|
588 |
|
589 |
with gr.Blocks() as demo:
|
|
|
546 |
lines = blog_post.split('\n')
|
547 |
title = lines[0].strip()
|
548 |
|
549 |
+
# 1. ์ ๋ชฉ์ ๋ํ ์์ฝ์ผ๋ก ๊ฐ์ ๋ชฉ์ ์ด๋ฏธ์ง ์์ฑ
|
550 |
+
title_prompt = f"Conceptual overview image representing '{title}'. Visual summary, infographic style, key concepts illustrated"
|
551 |
images.append(generate_image(title_prompt))
|
552 |
|
553 |
# ๋์
๋ถ์ ๋ณธ๋ฌธ, ๊ฒฐ๋ก ์ฐพ๊ธฐ
|
|
|
555 |
body_index = next((i for i, line in enumerate(lines) if '[๋ณธ๋ก 1]' in line), -1)
|
556 |
conclusion_index = next((i for i, line in enumerate(lines) if '[๊ฒฐ๋ก ]' in line), -1)
|
557 |
|
558 |
+
# 2. ๋์
๋ถ์ ๋ํ ์์ฝ์ผ๋ก ํฅ๋ฏธ ์ ๋ฐ ๋ชฉ์ ์ด๋ฏธ์ง ์์ฑ
|
559 |
if intro_index != -1 and body_index != -1:
|
560 |
intro_text = ' '.join(lines[intro_index+1:body_index])
|
561 |
+
intro_summary = f"Engaging and intriguing image to spark interest: {intro_text[:100]}... Eye-catching, thought-provoking, visually appealing"
|
562 |
images.append(generate_image(intro_summary))
|
563 |
|
564 |
+
# 3. ๋ณธ๋ฌธ ๋ด์ฉ ์์ฝ์ผ๋ก ์ด๋ฏธ์ง ์์ฑ
|
565 |
if body_index != -1 and conclusion_index != -1:
|
566 |
body_text = ' '.join(lines[body_index+1:conclusion_index])
|
567 |
+
body_summary = f"Detailed illustration of main content: {body_text[:100]}... Informative, clear visualization, key points highlighted"
|
568 |
images.append(generate_image(body_summary))
|
569 |
|
570 |
+
# 4. ๊ฒฐ๋ก ๋ด์ฉ ์์ฝ์ผ๋ก ๋
์์๊ฒ ์ ๊ณต๋๋ ๊ฐ์น์ ์ด์ต์ ์ด๋ฏธ์ง๋ก ์์ฑ
|
571 |
if conclusion_index != -1:
|
572 |
conclusion_text = ' '.join(lines[conclusion_index+1:])
|
573 |
+
value_summary = f"Image symbolizing the value and benefits for readers: {conclusion_text[:100]}... Positive outcomes, achievements, growth visualization"
|
574 |
+
images.append(generate_image(value_summary))
|
575 |
|
576 |
+
# 5. ๊ฒฐ๋ก ๋ด์ฉ ์์ฝ์ผ๋ก ์์ง์ ์ด๋ฏธ์ง๋ก ์์ฑ
|
577 |
if conclusion_index != -1:
|
578 |
+
symbolic_summary = f"Symbolic representation of the conclusion: {conclusion_text[:100]}... Abstract, metaphorical, thought-provoking imagery"
|
579 |
+
images.append(generate_image(symbolic_summary))
|
580 |
|
581 |
# ๋ง์ฝ ์์ฑ๋ ์ด๋ฏธ์ง๊ฐ 5๊ฐ ๋ฏธ๋ง์ด๋ผ๋ฉด, ๋ถ์กฑํ ๋งํผ ์๋ก์ด ์ด๋ฏธ์ง๋ฅผ ์์ฑ
|
582 |
while len(images) < 5:
|
583 |
+
random_prompt = f"Supplementary image related to: {title}. Diverse, relevant, complementary visual"
|
584 |
images.append(generate_image(random_prompt))
|
585 |
|
586 |
+
return images[:5] # ์ต๋ 5๊ฐ์ ์ด๋ฏธ์ง๋ง ๋ฐํ
|
587 |
|
588 |
|
589 |
with gr.Blocks() as demo:
|