Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
import requests
|
3 |
from bs4 import BeautifulSoup
|
@@ -20,7 +21,6 @@ from urllib.parse import urljoin
|
|
20 |
import requests
|
21 |
from pexels_api import API
|
22 |
import logging
|
23 |
-
import random
|
24 |
|
25 |
# ๋ก๊น
์ค์
|
26 |
logging.basicConfig(level=logging.INFO)
|
@@ -620,13 +620,18 @@ def convert_markdown_images(content):
|
|
620 |
|
621 |
return content
|
622 |
|
|
|
623 |
def process_all_titles(category, style, topic, num_titles):
|
624 |
title_suggestions, _ = suggest_title(category, style, topic, "", "", "")
|
625 |
titles = title_suggestions.split('\n')
|
|
|
|
|
|
|
626 |
|
627 |
results = []
|
628 |
for title in titles[:num_titles]:
|
629 |
try:
|
|
|
630 |
# ์ฒซ ๋ฒ์งธ ์ด๋ฏธ์ง URL ๊ฐ์ ธ์ค๊ธฐ
|
631 |
image_url_1 = get_image_url(topic)
|
632 |
|
@@ -706,7 +711,7 @@ with gr.Blocks() as demo:
|
|
706 |
gr.Markdown("### 3๋จ๊ณ : ๋ธ๋ก๊ทธ ์ฃผ์ , ๋๋ ํค์๋๋ฅผ ์์ธํ ์
๋ ฅํ์ธ์")
|
707 |
topic = gr.Textbox(label="๋ธ๋ก๊ทธ ์ฃผ์ ", placeholder="์์: 8์ ๊ตญ๋ด ์ฌํ์ง ์ถ์ฒ")
|
708 |
|
709 |
-
gr.Markdown("### 4๋จ๊ณ : ์๋ ์์ฑ ๋ฐ ์ ์กํ ๋ธ๋ก๊ทธ ์(๊ณ์ ๋น ์ผ์ผ ํฌ์คํ
์
๋ก๋ ์ ํ 60
|
710 |
num_titles = gr.Slider(minimum=1, maximum=60, value=2, step=1, label="ํฌ์คํ
๊ฑด")
|
711 |
|
712 |
start_btn = gr.Button("์์")
|
|
|
1 |
+
import html
|
2 |
import gradio as gr
|
3 |
import requests
|
4 |
from bs4 import BeautifulSoup
|
|
|
21 |
import requests
|
22 |
from pexels_api import API
|
23 |
import logging
|
|
|
24 |
|
25 |
# ๋ก๊น
์ค์
|
26 |
logging.basicConfig(level=logging.INFO)
|
|
|
620 |
|
621 |
return content
|
622 |
|
623 |
+
|
624 |
def process_all_titles(category, style, topic, num_titles):
|
625 |
title_suggestions, _ = suggest_title(category, style, topic, "", "", "")
|
626 |
titles = title_suggestions.split('\n')
|
627 |
+
|
628 |
+
# ๋น ๋ฌธ์์ด์ด๋ '###' ๋ฑ์ ๋ถํ์ํ ๋ฌธ์์ด ์ ๊ฑฐ
|
629 |
+
titles = [title.strip() for title in titles if title.strip() and not title.strip().startswith('###')]
|
630 |
|
631 |
results = []
|
632 |
for title in titles[:num_titles]:
|
633 |
try:
|
634 |
+
|
635 |
# ์ฒซ ๋ฒ์งธ ์ด๋ฏธ์ง URL ๊ฐ์ ธ์ค๊ธฐ
|
636 |
image_url_1 = get_image_url(topic)
|
637 |
|
|
|
711 |
gr.Markdown("### 3๋จ๊ณ : ๋ธ๋ก๊ทธ ์ฃผ์ , ๋๋ ํค์๋๋ฅผ ์์ธํ ์
๋ ฅํ์ธ์")
|
712 |
topic = gr.Textbox(label="๋ธ๋ก๊ทธ ์ฃผ์ ", placeholder="์์: 8์ ๊ตญ๋ด ์ฌํ์ง ์ถ์ฒ")
|
713 |
|
714 |
+
gr.Markdown("### 4๋จ๊ณ : ์๋ ์์ฑ ๋ฐ ์ ์กํ ๋ธ๋ก๊ทธ ์(๊ณ์ ๋น ์ผ์ผ ํฌ์คํ
์
๋ก๋ ์ ํ 60๊ฑด๊น์ง )")
|
715 |
num_titles = gr.Slider(minimum=1, maximum=60, value=2, step=1, label="ํฌ์คํ
๊ฑด")
|
716 |
|
717 |
start_btn = gr.Button("์์")
|