GitHub Actions Bot commited on
Commit
1d1c6cc
·
0 Parent(s):

Update Multi_Model_Streamlit

Browse files
Files changed (3) hide show
  1. README.md +11 -0
  2. app.py +25 -0
  3. requirements.txt +3 -0
README.md ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Multi-Model Streamlit App
3
+ emoji: 📊
4
+ colorFrom: indigo
5
+ colorTo: purple
6
+ sdk: streamlit
7
+ app_file: app.py
8
+ pinned: false
9
+ ---
10
+
11
+ This is a Streamlit application deployed as a Hugging Face Space..
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import requests
3
+ from PIL import Image
4
+ from io import BytesIO
5
+
6
+ st.title("Image Captioning App")
7
+ #test123
8
+ # Upload image
9
+ uploaded_image = st.file_uploader("Upload an image", type=["jpg", "jpeg", "png"])
10
+
11
+ if uploaded_image is not None:
12
+ # Display the uploaded image
13
+ st.image(uploaded_image, caption="Uploaded Image.", use_column_width=True)
14
+
15
+ # Call the FastAPI backend for caption generation
16
+ if st.button("Generate Caption"):
17
+ # Send image to FastAPI backend
18
+ image_bytes = uploaded_image.read()
19
+ response = requests.post("https://nihalk-fastapi-multimodal-app.hf.space/generate-caption", files={"image": image_bytes})
20
+
21
+ if response.status_code == 200:
22
+ caption = response.json().get("caption", "No caption generated.")
23
+ st.subheader(f"Generated Caption: {caption}")
24
+ else:
25
+ st.error(f"Error: {response.json().get('detail', 'Unknown error.')}")
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ streamlit
2
+ requests
3
+ Pillow