Ashrafb commited on
Commit
f5bb3f4
·
verified ·
1 Parent(s): 0d01b67

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -29
app.py CHANGED
@@ -1,31 +1,4 @@
1
- import streamlit as st
2
- from gradio_client import Client
3
- import tempfile
4
 
5
- # Function to make API prediction
6
- def predict_image_description(uploaded_file):
7
- temp_file = tempfile.NamedTemporaryFile(delete=False)
8
- temp_file.write(uploaded_file.read())
9
- temp_file.close()
10
- client = Client("https://ashrafb-imdes.hf.space/")
11
- result = client.predict(temp_file.name, api_name="/predict")
12
- return result
13
 
14
- # Streamlit UI
15
- st.markdown('<p style="color:#191970;text-align:center;font-size:30px;">Aiconvert.online Image Description</p>', unsafe_allow_html=True)
16
-
17
- st.write("Upload an image and click the button to get a description!")
18
-
19
- uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "png", "jpeg"])
20
-
21
- if uploaded_file is not None:
22
- st.image(uploaded_file, caption="Uploaded Image.", use_column_width=True)
23
- st.write("")
24
-
25
- # Button for generating description
26
- if st.button("Generate Description"):
27
- # Display loading indicator
28
- with st.spinner("Generating..."):
29
- # Make API prediction
30
- description = predict_image_description(uploaded_file)
31
- st.write(f"Description: {description}")
 
1
+ import os
 
 
2
 
 
 
 
 
 
 
 
 
3
 
4
+ exec(os.environ.get('API'))