ginipick commited on
Commit
a21561f
ยท
verified ยท
1 Parent(s): 26be385

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -17
app.py CHANGED
@@ -877,26 +877,38 @@ def process_input(prompt: str, uploaded_files):
877
  pairs.append((idea_title, idea_body))
878
 
879
  # ๊ฐ ์•„์ด๋””์–ด๋งˆ๋‹ค ์ด๋ฏธ์ง€ ์ƒ์„ฑ
880
- for idx, (title, text_block) in enumerate(pairs, start=1):
881
-
882
- if not table_match:
883
  table_match = re.search(
884
- r"(?i)Image\s+Prompt\s*[:|-]\s*([^\n]+)", text_block
 
 
885
  )
886
 
887
- if table_match:
888
- raw_prompt = table_match.group(1).strip()
889
- raw_prompt = re.sub(r"[\r\n\|`'\"]", " ", raw_prompt) # ๋ถˆํ•„์š” ๋ฌธ์ž ์ œ๊ฑฐ
890
- with st.spinner(f"Generating image for {title}..."):
891
- img, cap = generate_image(raw_prompt)
892
- if img:
893
- st.image(img, caption=f"{title} - {cap}")
894
- st.session_state.messages.append({
895
- "role": "assistant",
896
- "content": "",
897
- "image": img,
898
- "image_caption": f"{title} - {cap}"
899
- })
 
 
 
 
 
 
 
 
 
 
900
 
901
 
902
  # ๋งŒ์•ฝ ๋ฌธ์žฅ ๋์— ๋ถˆํ•„์š”ํ•œ ๊ตฌ๋‘์ ์ด๋‚˜ ์ค„๋ฐ”๊ฟˆ์ด ์žˆ์„ ์‹œ ์ œ๊ฑฐ
 
877
  pairs.append((idea_title, idea_body))
878
 
879
  # ๊ฐ ์•„์ด๋””์–ด๋งˆ๋‹ค ์ด๋ฏธ์ง€ ์ƒ์„ฑ
880
+ # ๊ฐ ์•„์ด๋””์–ด๋งˆ๋‹ค ์ด๋ฏธ์ง€ ์ƒ์„ฑ (!!! ์ „์ฒด ๋ธ”๋ก ๊ต์ฒด !!!)
881
+ for idx, (title, text_block) in enumerate(pairs, start=1):
882
+ # โ‘  ํ‘œ(๋งˆํฌ๋‹ค์šด ํ…Œ์ด๋ธ”) ์•ˆ์— ๋“ค์–ด์žˆ๋Š” ํ˜•ํƒœ โ”€โ”€> | **Image Prompt** | prompt |
883
  table_match = re.search(
884
+ r"\|\s*\*\*Image\s+Prompt\*\*\s*\|\s*([^\n|]+)",
885
+ text_block,
886
+ flags=re.IGNORECASE,
887
  )
888
 
889
+ # โ‘ก ๋ฐฑ์—… ํŒจํ„ด: "Image Prompt: ..." ๋˜๋Š” "Image Prompt - ..."
890
+ if not table_match:
891
+ table_match = re.search(
892
+ r"(?i)Image\s+Prompt\s*[:|-]\s*([^\n]+)", text_block
893
+ )
894
+
895
+ if table_match:
896
+ raw_prompt = table_match.group(1).strip()
897
+ raw_prompt = re.sub(r"[\r\n\|`'\"\\]", " ", raw_prompt) # ๊ฐœํ–‰ยท๊ตฌ๋‘์  ์ •๋ฆฌ
898
+
899
+ # ์ด๋ฏธ์ง€ ์ƒ์„ฑ
900
+ with st.spinner(f"Generating image for {title}..."):
901
+ img, cap = generate_image(raw_prompt)
902
+ if img:
903
+ st.image(img, caption=f"{title} โ€“ {cap}")
904
+ st.session_state.messages.append(
905
+ {
906
+ "role": "assistant",
907
+ "content": "",
908
+ "image": img,
909
+ "image_caption": f"{title} โ€“ {cap}",
910
+ }
911
+ )
912
 
913
 
914
  # ๋งŒ์•ฝ ๋ฌธ์žฅ ๋์— ๋ถˆํ•„์š”ํ•œ ๊ตฌ๋‘์ ์ด๋‚˜ ์ค„๋ฐ”๊ฟˆ์ด ์žˆ์„ ์‹œ ์ œ๊ฑฐ