fantaxy commited on
Commit
9e84d1a
·
verified ·
1 Parent(s): 3e57a2d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -527,19 +527,19 @@ def generate_images(blog_post):
527
  title = lines[0].strip()
528
 
529
  # 1. 제목을 요약하여 이미지 생성
530
- images.append(generate_image(f"Summary of '{title}'"))
 
531
 
532
  # 도입부와 본문, 결론 찾기
533
  intro_index = next((i for i, line in enumerate(lines) if '[도입부]' in line), -1)
534
  body_index = next((i for i, line in enumerate(lines) if '[본론1]' in line), -1)
535
  conclusion_index = next((i for i, line in enumerate(lines) if '[결론]' in line), -1)
536
 
537
- # 2. 도입부 요약으로 이미지 2장 생성
538
  if intro_index != -1 and body_index != -1:
539
  intro_text = ' '.join(lines[intro_index+1:body_index])
540
  intro_summary = f"Summary of introduction: {intro_text[:100]}..."
541
  images.append(generate_image(intro_summary))
542
- images.append(generate_image(intro_summary))
543
 
544
  # 3. 본문 요약으로 이미지 생성
545
  if body_index != -1 and conclusion_index != -1:
@@ -558,11 +558,12 @@ def generate_images(blog_post):
558
  value_summary = f"Image symbolizing the value and benefit for readers: {conclusion_text[:100]}..."
559
  images.append(generate_image(value_summary))
560
 
561
- # 만약 생성된 이미지가 5개 미만이라면, 부족한 만큼 마지막 이미지를 복제
562
  while len(images) < 5:
563
- images.append(images[-1] if images else "")
 
564
 
565
- return images
566
 
567
 
568
  with gr.Blocks() as demo:
 
527
  title = lines[0].strip()
528
 
529
  # 1. 제목을 요약하여 이미지 생성
530
+ title_prompt = f"Summary of '{title}'"
531
+ images.append(generate_image(title_prompt))
532
 
533
  # 도입부와 본문, 결론 찾기
534
  intro_index = next((i for i, line in enumerate(lines) if '[도입부]' in line), -1)
535
  body_index = next((i for i, line in enumerate(lines) if '[본론1]' in line), -1)
536
  conclusion_index = next((i for i, line in enumerate(lines) if '[결론]' in line), -1)
537
 
538
+ # 2. 도입부 요약으로 이미지 1장 생성
539
  if intro_index != -1 and body_index != -1:
540
  intro_text = ' '.join(lines[intro_index+1:body_index])
541
  intro_summary = f"Summary of introduction: {intro_text[:100]}..."
542
  images.append(generate_image(intro_summary))
 
543
 
544
  # 3. 본문 요약으로 이미지 생성
545
  if body_index != -1 and conclusion_index != -1:
 
558
  value_summary = f"Image symbolizing the value and benefit for readers: {conclusion_text[:100]}..."
559
  images.append(generate_image(value_summary))
560
 
561
+ # 만약 생성된 이미지가 5개 미만이라면, 부족한 만큼 새로운 이미지를 생성
562
  while len(images) < 5:
563
+ random_prompt = f"Random image related to: {title}"
564
+ images.append(generate_image(random_prompt))
565
 
566
+ return images[:5] # 최대 5개의 이미지만 반환: 제목 1장, 도입부 1장, 본문 1장, 결론 2장 = 5장
567
 
568
 
569
  with gr.Blocks() as demo: