File size: 1,833 Bytes
61d3424
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#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)