yongyeol commited on
Commit
60286a6
Β·
verified Β·
1 Parent(s): 06a81df

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -63
app.py DELETED
@@ -1,63 +0,0 @@
1
- import streamlit as st
2
- import requests
3
- import base64
4
- from PIL import Image
5
- from io import BytesIO
6
-
7
- # ───────────────────────────────
8
- # CONFIG
9
- # ───────────────────────────────
10
- st.set_page_config(page_title="동화 μ‚½ν™” 생성기", layout="wide")
11
- API_URL = "https://api-inference.huggingface.co/models/black-forest-labs/FLUX.1-Kontext-dev"
12
- headers = {"Authorization": f"Bearer {st.secrets['HF_TOKEN']}"}
13
-
14
- # ───────────────────────────────
15
- # UTILS
16
- # ───────────────────────────────
17
- def query_flux(prompt, image_bytes=None):
18
- inputs = {"prompt": prompt}
19
- if image_bytes:
20
- inputs["image"] = base64.b64encode(image_bytes).decode("utf-8")
21
-
22
- response = requests.post(API_URL, headers=headers, json=inputs)
23
- if response.status_code == 200:
24
- image_data = base64.b64decode(response.json()["image"])
25
- return Image.open(BytesIO(image_data))
26
- else:
27
- st.error(f"Error: {response.status_code} - {response.text}")
28
- return None
29
-
30
- # ───────────────────────────────
31
- # UI
32
- # ───────────────────────────────
33
- st.title("πŸ“š 동화 μ‚½ν™” 생성기 (FLUX.1 Kontext)")
34
- st.markdown("각 μž₯면의 μ„€λͺ…을 μž…λ ₯ν•˜λ©΄, 이야기 흐름에 λ§žλŠ” μ‚½ν™”λ₯Ό μžλ™μœΌλ‘œ μƒμ„±ν•©λ‹ˆλ‹€.")
35
-
36
- with st.expander("λ“±μž₯인물 및 μŠ€νƒ€μΌ 정보 (선택)"):
37
- character_prompt = st.text_area("λ“±μž₯인물 μ„€λͺ… (ex. λΉ¨κ°„ 망토λ₯Ό μ“΄ μ†Œλ…€, νšŒμƒ‰ λŠ‘λŒ€ λ“±)", height=100)
38
- reference_image = st.file_uploader("μ°Έμ‘° 이미지 μ—…λ‘œλ“œ (선택)", type=["jpg", "png"])
39
-
40
- st.markdown("### πŸ“ 동화 λ‚΄μš©μ„ 5개 μž₯면으둜 λ‚˜λˆ„μ–΄ μž…λ ₯ν•˜μ„Έμš”")
41
-
42
- scene_prompts = []
43
- for i in range(5):
44
- text = st.text_area(f"μž₯λ©΄ {i+1} μ„€λͺ…", key=f"scene_{i}", height=80)
45
- scene_prompts.append(text)
46
-
47
- if st.button("🎨 μ‚½ν™” μƒμ„±ν•˜κΈ°"):
48
- if not any(scene_prompts):
49
- st.warning("μ΅œμ†Œ ν•˜λ‚˜ μ΄μƒμ˜ μž₯λ©΄ μ„€λͺ…이 ν•„μš”ν•©λ‹ˆλ‹€.")
50
- else:
51
- ref_bytes = reference_image.read() if reference_image else None
52
-
53
- with st.spinner("이미지λ₯Ό 생성 μ€‘μž…λ‹ˆλ‹€..."):
54
- cols = st.columns(5)
55
- for i, prompt in enumerate(scene_prompts):
56
- if not prompt.strip():
57
- continue
58
-
59
- full_prompt = f"{character_prompt}. {prompt}" if character_prompt else prompt
60
- img = query_flux(full_prompt, ref_bytes)
61
- if img:
62
- cols[i].image(img, caption=f"μž₯λ©΄ {i+1}")
63
-