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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -3
app.py CHANGED
@@ -878,9 +878,27 @@ def process_input(prompt: str, uploaded_files):
878
 
879
  # ๊ฐ ์•„์ด๋””์–ด๋งˆ๋‹ค ์ด๋ฏธ์ง€ ์ƒ์„ฑ
880
  for idx, (title, text_block) in enumerate(pairs, start=1):
881
- image_prompt_match = re.search(r"(?i)(image prompt\s*\:\s*)(.+)", text_block)
882
- if image_prompt_match:
883
- raw_prompt = image_prompt_match.group(2).strip()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
884
  # ๋งŒ์•ฝ ๋ฌธ์žฅ ๋์— ๋ถˆํ•„์š”ํ•œ ๊ตฌ๋‘์ ์ด๋‚˜ ์ค„๋ฐ”๊ฟˆ์ด ์žˆ์„ ์‹œ ์ œ๊ฑฐ
885
  raw_prompt = re.sub(r"[\r\n]+", " ", raw_prompt)
886
  raw_prompt = re.sub(r"[\"'`]", "", raw_prompt)
 
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
  # ๋งŒ์•ฝ ๋ฌธ์žฅ ๋์— ๋ถˆํ•„์š”ํ•œ ๊ตฌ๋‘์ ์ด๋‚˜ ์ค„๋ฐ”๊ฟˆ์ด ์žˆ์„ ์‹œ ์ œ๊ฑฐ
903
  raw_prompt = re.sub(r"[\r\n]+", " ", raw_prompt)
904
  raw_prompt = re.sub(r"[\"'`]", "", raw_prompt)