Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -688,11 +688,11 @@ def idea_generator_app():
|
|
| 688 |
|
| 689 |
sb.subheader("Example Prompts")
|
| 690 |
c1, c2, c3 = sb.columns(3)
|
| 691 |
-
if c1.button("
|
| 692 |
process_example(example_topics["example1"])
|
| 693 |
-
if c2.button("
|
| 694 |
process_example(example_topics["example2"])
|
| 695 |
-
if c3.button("
|
| 696 |
process_example(example_topics["example3"])
|
| 697 |
|
| 698 |
# Download the latest ideas
|
|
@@ -880,42 +880,46 @@ def process_input(prompt: str, uploaded_files):
|
|
| 880 |
status.update(label="Ideas created!", state="complete")
|
| 881 |
|
| 882 |
# ββ β€ μ΄λ―Έμ§ μμ±
|
|
|
|
| 883 |
if st.session_state.generate_image and full_response:
|
| 884 |
|
| 885 |
-
|
| 886 |
-
|
| 887 |
-
|
| 888 |
-
|
| 889 |
-
|
| 890 |
-
|
| 891 |
-
|
| 892 |
-
|
| 893 |
-
|
| 894 |
-
r"\|\s*(?:\*\*)?Image\s+Prompt(?:\*\*)?\s*\|\s*([^|\n]+)",
|
| 895 |
-
|
| 896 |
-
|
| 897 |
-
|
| 898 |
-
|
| 899 |
-
|
| 900 |
-
|
| 901 |
-
|
| 902 |
-
|
| 903 |
-
|
| 904 |
-
raw_prompt = re.sub(r"[\r\n`\"'\\]", " ",
|
| 905 |
-
|
| 906 |
-
|
|
|
|
| 907 |
img, cap = generate_image(raw_prompt)
|
| 908 |
|
| 909 |
if img:
|
| 910 |
-
st.image(img, caption=f"
|
|
|
|
| 911 |
st.session_state.messages.append({
|
| 912 |
"role": "assistant",
|
| 913 |
"content": "",
|
| 914 |
"image": img,
|
| 915 |
-
"image_caption": f"
|
| 916 |
})
|
|
|
|
|
|
|
| 917 |
|
| 918 |
-
|
| 919 |
|
| 920 |
# ββ β₯ κ²°κ³Ό μ μ₯
|
| 921 |
st.session_state.messages.append(
|
|
|
|
| 688 |
|
| 689 |
sb.subheader("Example Prompts")
|
| 690 |
c1, c2, c3 = sb.columns(3)
|
| 691 |
+
if c1.button("λμ λ¬Ό λΆμ‘± λ¬Έμ ", key="ex1"):
|
| 692 |
process_example(example_topics["example1"])
|
| 693 |
+
if c2.button("λ
ΈμΈ λλ΄ μλΉμ€", key="ex2"):
|
| 694 |
process_example(example_topics["example2"])
|
| 695 |
+
if c3.button("μ§μκ°λ₯ν μν ν¬μ₯", key="ex3"):
|
| 696 |
process_example(example_topics["example3"])
|
| 697 |
|
| 698 |
# Download the latest ideas
|
|
|
|
| 880 |
status.update(label="Ideas created!", state="complete")
|
| 881 |
|
| 882 |
# ββ β€ μ΄λ―Έμ§ μμ±
|
| 883 |
+
# ββ β€ μ΄λ―Έμ§ μμ± (κΈ°μ‘΄ λΈλ‘ μ λΆ κ΅μ²΄) βββββββββββββββββββββββββββββ
|
| 884 |
if st.session_state.generate_image and full_response:
|
| 885 |
|
| 886 |
+
# 1οΈβ£ βΆ CCM μ€νμΌ: "### μ΄λ―Έμ§ ν둬ννΈ" ν€λ© μλ μ€
|
| 887 |
+
ccm_match = re.search(
|
| 888 |
+
r"###\s*μ΄λ―Έμ§\s*ν둬ννΈ\s*\n+([^\n]+)",
|
| 889 |
+
full_response, flags=re.IGNORECASE)
|
| 890 |
+
|
| 891 |
+
# 2οΈβ£ β· μ΄μ μ€νμΌ: ν
μ΄λΈ or "Image Prompt:"
|
| 892 |
+
legacy_match = None
|
| 893 |
+
if not ccm_match:
|
| 894 |
+
legacy_match = re.search(
|
| 895 |
+
r"\|\s*(?:\*\*)?Image\s+Prompt(?:\*\*)?\s*\|\s*([^|\n]+)",
|
| 896 |
+
full_response, flags=re.IGNORECASE)
|
| 897 |
+
if not legacy_match:
|
| 898 |
+
legacy_match = re.search(
|
| 899 |
+
r"(?i)Image\s+Prompt\s*[:\-]\s*([^\n]+)",
|
| 900 |
+
full_response)
|
| 901 |
+
|
| 902 |
+
# 3οΈβ£ μ΅μ’
ν둬ννΈ μΆμΆ
|
| 903 |
+
match = ccm_match or legacy_match
|
| 904 |
+
if match:
|
| 905 |
+
raw_prompt = re.sub(r"[\r\n`\"'\\]", " ",
|
| 906 |
+
match.group(1)).strip()
|
| 907 |
+
|
| 908 |
+
with st.spinner("μμ΄λμ΄ μ΄λ―Έμ§ μμ± μ€β¦"):
|
| 909 |
img, cap = generate_image(raw_prompt)
|
| 910 |
|
| 911 |
if img:
|
| 912 |
+
st.image(img, caption=f"μμ΄λμ΄ μκ°ν β {cap}")
|
| 913 |
+
# λν κΈ°λ‘μ μ΄λ―Έμ§λ μ μ₯
|
| 914 |
st.session_state.messages.append({
|
| 915 |
"role": "assistant",
|
| 916 |
"content": "",
|
| 917 |
"image": img,
|
| 918 |
+
"image_caption": f"μμ΄λμ΄ μκ°ν β {cap}"
|
| 919 |
})
|
| 920 |
+
|
| 921 |
+
|
| 922 |
|
|
|
|
| 923 |
|
| 924 |
# ββ β₯ κ²°κ³Ό μ μ₯
|
| 925 |
st.session_state.messages.append(
|