Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,28 +1,21 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
from PIL import Image
|
| 3 |
-
|
|
|
|
| 4 |
|
| 5 |
def main():
|
| 6 |
-
st.
|
| 7 |
-
st.title("Image Caption Generator")
|
| 8 |
|
| 9 |
uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
|
| 10 |
|
| 11 |
if uploaded_file is not None:
|
| 12 |
image = Image.open(uploaded_file)
|
| 13 |
-
st.image(image, caption=
|
| 14 |
|
| 15 |
-
if st.button(
|
| 16 |
-
|
| 17 |
-
# Generate initial caption
|
| 18 |
-
caption = generate_initial_caption(image)
|
| 19 |
-
|
| 20 |
-
st.success("Caption generated successfully!")
|
| 21 |
st.write("Generated Caption:")
|
| 22 |
st.write(caption)
|
| 23 |
-
|
| 24 |
-
# Add copy button
|
| 25 |
-
st.text_area("Copy caption", caption, height=100)
|
| 26 |
|
| 27 |
if __name__ == "__main__":
|
| 28 |
main()
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
from PIL import Image
|
| 3 |
+
import io
|
| 4 |
+
from image_to_text import generate_caption
|
| 5 |
|
| 6 |
def main():
|
| 7 |
+
st.title("Image Captioning App")
|
|
|
|
| 8 |
|
| 9 |
uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
|
| 10 |
|
| 11 |
if uploaded_file is not None:
|
| 12 |
image = Image.open(uploaded_file)
|
| 13 |
+
st.image(image, caption='Uploaded Image', use_column_width=True)
|
| 14 |
|
| 15 |
+
if st.button('Generate Caption'):
|
| 16 |
+
caption = generate_caption(image)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
st.write("Generated Caption:")
|
| 18 |
st.write(caption)
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
if __name__ == "__main__":
|
| 21 |
main()
|