Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,18 +9,45 @@ API_URL = "https://api.studio.nebius.ai/v1/chat/completions"
|
|
| 9 |
|
| 10 |
# Streamlit app configuration
|
| 11 |
st.set_page_config(page_title="Image to Prompt Converter", layout="centered", page_icon="🖼️")
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
# App title
|
| 15 |
st.title("Image to Prompt Converter")
|
| 16 |
-
st.markdown("Upload an image and generate a detailed prompt
|
| 17 |
|
| 18 |
# Image upload
|
| 19 |
uploaded_file = st.file_uploader("Upload an image", type=["jpg", "png", "jpeg"])
|
| 20 |
|
| 21 |
if uploaded_file is not None:
|
| 22 |
# Display the uploaded image
|
| 23 |
-
st.image(uploaded_file, caption="Uploaded Image",
|
| 24 |
|
| 25 |
# Generate button
|
| 26 |
if st.button("Generate Prompt"):
|
|
@@ -51,8 +78,6 @@ if uploaded_file is not None:
|
|
| 51 |
st.text_area("", generated_prompt, height=200)
|
| 52 |
|
| 53 |
# Copy button
|
| 54 |
-
|
| 55 |
-
st.write("Prompt copied to clipboard!")
|
| 56 |
-
st.write(generated_prompt)
|
| 57 |
else:
|
| 58 |
st.error(f"Failed to generate prompt: {response.status_code} - {response.text}")
|
|
|
|
| 9 |
|
| 10 |
# Streamlit app configuration
|
| 11 |
st.set_page_config(page_title="Image to Prompt Converter", layout="centered", page_icon="🖼️")
|
| 12 |
+
|
| 13 |
+
# Apply custom styles
|
| 14 |
+
st.markdown(
|
| 15 |
+
"""
|
| 16 |
+
<style>
|
| 17 |
+
body {
|
| 18 |
+
background: linear-gradient(135deg, #1e3c72, #2a5298);
|
| 19 |
+
color: #FFFFFF;
|
| 20 |
+
font-family: 'Arial', sans-serif;
|
| 21 |
+
}
|
| 22 |
+
.stApp {
|
| 23 |
+
align-items: center;
|
| 24 |
+
justify-content: center;
|
| 25 |
+
}
|
| 26 |
+
.css-1offfwp {
|
| 27 |
+
margin: auto !important;
|
| 28 |
+
}
|
| 29 |
+
h1, h2, h3 {
|
| 30 |
+
text-align: center;
|
| 31 |
+
}
|
| 32 |
+
.uploaded-image {
|
| 33 |
+
border-radius: 10px;
|
| 34 |
+
margin-bottom: 20px;
|
| 35 |
+
}
|
| 36 |
+
</style>
|
| 37 |
+
""",
|
| 38 |
+
unsafe_allow_html=True
|
| 39 |
+
)
|
| 40 |
|
| 41 |
# App title
|
| 42 |
st.title("Image to Prompt Converter")
|
| 43 |
+
st.markdown("**Upload an image and generate a detailed prompt.**")
|
| 44 |
|
| 45 |
# Image upload
|
| 46 |
uploaded_file = st.file_uploader("Upload an image", type=["jpg", "png", "jpeg"])
|
| 47 |
|
| 48 |
if uploaded_file is not None:
|
| 49 |
# Display the uploaded image
|
| 50 |
+
st.image(uploaded_file, caption="Uploaded Image", use_container_width=True, class_="uploaded-image")
|
| 51 |
|
| 52 |
# Generate button
|
| 53 |
if st.button("Generate Prompt"):
|
|
|
|
| 78 |
st.text_area("", generated_prompt, height=200)
|
| 79 |
|
| 80 |
# Copy button
|
| 81 |
+
st.button("Copy Prompt", on_click=lambda: st.session_state.update({"clipboard": generated_prompt}))
|
|
|
|
|
|
|
| 82 |
else:
|
| 83 |
st.error(f"Failed to generate prompt: {response.status_code} - {response.text}")
|