Spaces:
Build error
Build error
Leo Liu commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -28,21 +28,24 @@ def main():
|
|
| 28 |
st.markdown("""
|
| 29 |
<div class="header">
|
| 30 |
<h1>🪄 Magic Picture Story Box 🎧</h1>
|
| 31 |
-
<h4 style="color:#4ECDC4;">Upload any photo
|
| 32 |
</div>
|
| 33 |
""", unsafe_allow_html=True)
|
| 34 |
uploaded_file = st.file_uploader("🌈 Choose your magic picture...", type=["jpg", "png"])
|
| 35 |
|
| 36 |
if uploaded_file is not None:
|
| 37 |
-
|
| 38 |
bytes_data = uploaded_file.getvalue()
|
| 39 |
with open(uploaded_file.name, "wb") as file:
|
| 40 |
file.write(bytes_data)
|
| 41 |
-
st.image(uploaded_file, caption="
|
| 42 |
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
-
#Stage 1: Image to Text
|
| 45 |
-
with status_container.status("🔮 **Step 1/3**: Decoding picture magic...", expanded=True) as status:
|
| 46 |
progress_bar.progress(33)
|
| 47 |
scenario = img2text(uploaded_file.name)
|
| 48 |
status.update(label="✅ Picture decoded!", state="complete")
|
|
|
|
| 28 |
st.markdown("""
|
| 29 |
<div class="header">
|
| 30 |
<h1>🪄 Magic Picture Story Box 🎧</h1>
|
| 31 |
+
<h4 style="color:#4ECDC4;">Upload any photo to Get a fairy tale!</h4>
|
| 32 |
</div>
|
| 33 |
""", unsafe_allow_html=True)
|
| 34 |
uploaded_file = st.file_uploader("🌈 Choose your magic picture...", type=["jpg", "png"])
|
| 35 |
|
| 36 |
if uploaded_file is not None:
|
| 37 |
+
# 保存上传文件(原有逻辑)
|
| 38 |
bytes_data = uploaded_file.getvalue()
|
| 39 |
with open(uploaded_file.name, "wb") as file:
|
| 40 |
file.write(bytes_data)
|
| 41 |
+
st.image(uploaded_file, caption="Your Magic Picture ✨", use_container_width=True)
|
| 42 |
|
| 43 |
+
# 初始化状态容器(修复点:移出if块)
|
| 44 |
+
status_container = st.empty() # 移动到此处
|
| 45 |
+
progress_bar = st.progress(0)
|
| 46 |
|
| 47 |
+
# Stage 1: Image to Text
|
| 48 |
+
with status_container.status("🔮 **Step 1/3**: Decoding picture magic...", expanded=True) as status: # 保持缩进
|
| 49 |
progress_bar.progress(33)
|
| 50 |
scenario = img2text(uploaded_file.name)
|
| 51 |
status.update(label="✅ Picture decoded!", state="complete")
|