Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,13 +9,20 @@ def main():
|
|
| 9 |
uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
|
| 10 |
|
| 11 |
if uploaded_file is not None:
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
if __name__ == "__main__":
|
| 21 |
main()
|
|
|
|
| 9 |
uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
|
| 10 |
|
| 11 |
if uploaded_file is not None:
|
| 12 |
+
try:
|
| 13 |
+
image = Image.open(uploaded_file)
|
| 14 |
+
st.image(image, caption='Uploaded Image', use_column_width=True)
|
| 15 |
+
|
| 16 |
+
if st.button('Generate Caption'):
|
| 17 |
+
with st.spinner('Generating caption...'):
|
| 18 |
+
try:
|
| 19 |
+
caption = generate_caption(image)
|
| 20 |
+
st.write("Generated Caption:")
|
| 21 |
+
st.write(caption)
|
| 22 |
+
except Exception as e:
|
| 23 |
+
st.error(f"An error occurred while generating the caption: {str(e)}")
|
| 24 |
+
except Exception as e:
|
| 25 |
+
st.error(f"An error occurred while processing the image: {str(e)}")
|
| 26 |
|
| 27 |
if __name__ == "__main__":
|
| 28 |
main()
|