fantaxy commited on
Commit
bf1b428
ยท
verified ยท
1 Parent(s): 728d17c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -14
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"Summary of '{title}'"
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. ๋„์ž…๋ถ€ ์š”์•ฝ์œผ๋กœ ์ด๋ฏธ์ง€ 1์žฅ ์ƒ์„ฑ
559
  if intro_index != -1 and body_index != -1:
560
  intro_text = ' '.join(lines[intro_index+1:body_index])
561
- intro_summary = f"Summary of introduction: {intro_text[:100]}..."
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"Summary of main content: {body_text[:100]}..."
568
  images.append(generate_image(body_summary))
569
 
570
- # 4. ๊ฒฐ๋ก  ์š”์•ฝ์œผ๋กœ ์ƒ์ง•์  ์ด๋ฏธ์ง€ ์ƒ์„ฑ
571
  if conclusion_index != -1:
572
  conclusion_text = ' '.join(lines[conclusion_index+1:])
573
- conclusion_summary = f"Symbolic image representing: {conclusion_text[:100]}..."
574
- images.append(generate_image(conclusion_summary))
575
 
576
- # 5. ๊ฒฐ๋ก  ์š”์•ฝ์œผ๋กœ ๊ฐ€์น˜์™€ ์ด์ต์„ ์ƒ์ง•ํ•˜๋Š” ์ด๋ฏธ์ง€ ์ƒ์„ฑ
577
  if conclusion_index != -1:
578
- value_summary = f"Image symbolizing the value and benefit for readers: {conclusion_text[:100]}..."
579
- images.append(generate_image(value_summary))
580
 
581
  # ๋งŒ์•ฝ ์ƒ์„ฑ๋œ ์ด๋ฏธ์ง€๊ฐ€ 5๊ฐœ ๋ฏธ๋งŒ์ด๋ผ๋ฉด, ๋ถ€์กฑํ•œ ๋งŒํผ ์ƒˆ๋กœ์šด ์ด๋ฏธ์ง€๋ฅผ ์ƒ์„ฑ
582
  while len(images) < 5:
583
- random_prompt = f"Random image related to: {title}"
584
  images.append(generate_image(random_prompt))
585
 
586
- return images[:5] # ์ตœ๋Œ€ 5๊ฐœ์˜ ์ด๋ฏธ์ง€๋งŒ ๋ฐ˜ํ™˜: ์ œ๋ชฉ 1์žฅ, ๋„์ž…๋ถ€ 1์žฅ, ๋ณธ๋ฌธ 1์žฅ, ๊ฒฐ๋ก  2์žฅ = 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: