fantaxy commited on
Commit
06ae8eb
ยท
verified ยท
1 Parent(s): bf1b428

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -22
app.py CHANGED
@@ -556,35 +556,25 @@ def generate_images(blog_post):
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:
590
  gr.Markdown(f"# {title}")
 
556
  conclusion_index = next((i for i, line in enumerate(lines) if '[๊ฒฐ๋ก ]' in line), -1)
557
 
558
  # 2. ๋„์ž…๋ถ€์— ๋Œ€ํ•œ ์š”์•ฝ์œผ๋กœ ํฅ๋ฏธ ์œ ๋ฐœ ๋ชฉ์  ์ด๋ฏธ์ง€ ์ƒ์„ฑ
559
+ intro_text = ' '.join(lines[intro_index+1:body_index]) if intro_index != -1 and body_index != -1 else title
560
+ intro_summary = f"Engaging and intriguing image to spark interest: {intro_text[:100]}... Eye-catching, thought-provoking, visually appealing"
561
+ images.append(generate_image(intro_summary))
 
562
 
563
  # 3. ๋ณธ๋ฌธ ๋‚ด์šฉ ์š”์•ฝ์œผ๋กœ ์ด๋ฏธ์ง€ ์ƒ์„ฑ
564
+ body_text = ' '.join(lines[body_index+1:conclusion_index]) if body_index != -1 and conclusion_index != -1 else title
565
+ body_summary = f"Detailed illustration of main content: {body_text[:100]}... Informative, clear visualization, key points highlighted"
566
+ images.append(generate_image(body_summary))
 
567
 
568
  # 4. ๊ฒฐ๋ก  ๋‚ด์šฉ ์š”์•ฝ์œผ๋กœ ๋…์ž์—๊ฒŒ ์ œ๊ณต๋˜๋Š” ๊ฐ€์น˜์™€ ์ด์ต์„ ์ด๋ฏธ์ง€๋กœ ์ƒ์„ฑ
569
+ conclusion_text = ' '.join(lines[conclusion_index+1:]) if conclusion_index != -1 else title
570
+ value_summary = f"Image symbolizing the value and benefits for readers: {conclusion_text[:100]}... Positive outcomes, achievements, growth visualization"
571
+ images.append(generate_image(value_summary))
 
572
 
573
  # 5. ๊ฒฐ๋ก  ๋‚ด์šฉ ์š”์•ฝ์œผ๋กœ ์ƒ์ง•์„ ์ด๋ฏธ์ง€๋กœ ์ƒ์„ฑ
574
+ symbolic_summary = f"Symbolic representation of the conclusion: {conclusion_text[:100]}... Abstract, metaphorical, thought-provoking imagery"
575
+ images.append(generate_image(symbolic_summary))
 
576
 
577
+ return images # ํ•ญ์ƒ 5๊ฐœ์˜ ์ด๋ฏธ์ง€๋ฅผ ๋ฐ˜ํ™˜
 
 
 
 
 
 
578
 
579
  with gr.Blocks() as demo:
580
  gr.Markdown(f"# {title}")