#streamlit_image_selector.py import streamlit as st from bing_image_search import search_bing_images from generate_guide import generate_photo_guide # ✅ 이전 단계에서 저장한 caption 불러오기 (없으면 기본값) user_caption = st.session_state.get("caption", "shadow couple heart pose") st.title("유사한 감성 사진을 선택해주세요") st.markdown(f"**BLIP 모델이 생성한 설명:** {user_caption}") if st.button("유사 이미지 검색"): with st.spinner("이미지를 불러오는 중..."): image_urls = search_bing_images(user_caption) if not image_urls: st.error("❌ 이미지를 찾을 수 없습니다.") else: cols = st.columns(3) selections = [] st.subheader("원하는 스타일의 사진을 선택하세요 (1개 이상)") for i, url in enumerate(image_urls): with cols[i % 3]: st.image(url, use_column_width=True) if st.checkbox(f"선택 #{i+1}", key=f"chk_{i}"): selections.append(url) st.markdown("---") if st.button("선택 완료"): if not selections: st.warning("1개 이상 선택해주세요!") else: st.session_state.selected_images = selections st.success(f"✅ {len(selections)}장 선택됨!") # 👉 선택된 이미지 확인 st.write("선택된 이미지 URL:") for url in selections: st.write(url) # 👉 연출 가이드 생성 with st.spinner("연출 가이드를 생성하는 중..."): guide = generate_photo_guide(user_caption, selections) st.markdown("## 📸 연출 가이드") st.write(guide)