ProfessorLeVesseur commited on
Commit
506b62a
·
verified ·
1 Parent(s): 9622677

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -146,7 +146,7 @@ def encode_image(image_file):
146
  return base64.b64encode(image_file.getvalue()).decode("utf-8")
147
 
148
  # Streamlit page setup
149
- st.set_page_config(page_title="MTSS Image Accessibility Alt Text Generator", layout="centered", initial_sidebar_state="expanded")
150
 
151
  #Add the image with a specified width
152
  image_width = 300 # Set the desired width in pixels
@@ -162,6 +162,8 @@ openai.api_key = st.secrets["openai_api_key"]
162
  # File uploader allows user to add their own image
163
  # uploaded_file = st.file_uploader("Upload an image", type=["jpg", "png", "jpeg"])
164
 
 
 
165
  # Move the file uploader to the sidebar
166
  uploaded_file = st.sidebar.file_uploader("Upload an image", type=["jpg", "png", "jpeg"])
167
 
@@ -169,7 +171,7 @@ if uploaded_file:
169
  # Display the uploaded image with specified width
170
  image_width = 100 # Set the desired width in pixels
171
  with st.expander("Image", expanded=True):
172
- st.image(uploaded_file, caption=uploaded_file.name, width=image_width, use_column_width=False)
173
 
174
  # Toggle for showing additional details input
175
  show_details = st.toggle("Add details about the image. ", value=False)
@@ -251,7 +253,7 @@ if uploaded_file is not None and analyze_button:
251
  # Stream the response
252
  full_response = ""
253
  message_placeholder = st.empty()
254
- for completion in client.chat.completions.create(
255
  model="gpt-4-vision-preview", messages=messages,
256
  max_tokens=1200, stream=True
257
  ):
 
146
  return base64.b64encode(image_file.getvalue()).decode("utf-8")
147
 
148
  # Streamlit page setup
149
+ st.set_page_config(page_title="MTSS Image Accessibility Alt Text Generator", layout="centered", initial_sidebar_state="collapsed")
150
 
151
  #Add the image with a specified width
152
  image_width = 300 # Set the desired width in pixels
 
162
  # File uploader allows user to add their own image
163
  # uploaded_file = st.file_uploader("Upload an image", type=["jpg", "png", "jpeg"])
164
 
165
+ st.write("Please open the sidebar to upload an image.")
166
+
167
  # Move the file uploader to the sidebar
168
  uploaded_file = st.sidebar.file_uploader("Upload an image", type=["jpg", "png", "jpeg"])
169
 
 
171
  # Display the uploaded image with specified width
172
  image_width = 100 # Set the desired width in pixels
173
  with st.expander("Image", expanded=True):
174
+ st.sidebar.image(uploaded_file, caption=uploaded_file.name, width=image_width, use_column_width=False)
175
 
176
  # Toggle for showing additional details input
177
  show_details = st.toggle("Add details about the image. ", value=False)
 
253
  # Stream the response
254
  full_response = ""
255
  message_placeholder = st.empty()
256
+ for completion in openai.chat.completions.create(
257
  model="gpt-4-vision-preview", messages=messages,
258
  max_tokens=1200, stream=True
259
  ):