ProfessorLeVesseur commited on
Commit
6e79c2f
·
verified ·
1 Parent(s): a0e053b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -60
app.py CHANGED
@@ -1,62 +1,3 @@
1
- # import streamlit as st
2
- # import base64
3
- # import openai
4
-
5
- # # Function to encode the image to base64
6
- # def encode_image(image_file):
7
- # return base64.b64encode(image_file.getvalue()).decode("utf-8")
8
-
9
- # # Streamlit page setup
10
- # st.set_page_config(page_title="MTSS Image Accessibility Alt Text Generator", layout="centered", initial_sidebar_state="collapsed")
11
-
12
- # #Add the image with a specified width
13
- # image_width = 300 # Set the desired width in pixels
14
- # st.image('MTSS.ai_Logo.png', width=image_width)
15
-
16
- # st.title('VisionText™ | Accessibility')
17
- # st.subheader(':green[_Image Alt Text Generator_]')
18
-
19
- # # Retrieve the OpenAI API Key from secrets
20
- # openai.api_key = st.secrets["openai_api_key"]
21
-
22
- # # File uploader allows user to add their own image
23
- # uploaded_file = st.file_uploader("Upload an image", type=["jpg", "png", "jpeg"])
24
-
25
- # if uploaded_file:
26
- # # Display the uploaded image with specified width
27
- # image_width = 150 # Set the desired width in pixels
28
- # with st.expander("Image", expanded=True):
29
- # st.image(uploaded_file, caption=uploaded_file.name, width=image_width, use_column_width=False)
30
-
31
- # # Toggle for showing additional details input
32
- # show_details = st.toggle("Optional: Add details about the image. "
33
- # "The details could include specific information that is important to include in the alt text or reflect why the image is being used.", value=False)
34
-
35
- # if show_details:
36
- # # Text input for additional details about the image, shown only if toggle is True
37
- # additional_details = st.text_area(
38
- # "Add any additional details or context about the image here:",
39
- # disabled=not show_details
40
- # )
41
-
42
- # # Button to trigger the analysis
43
- # analyze_button = st.button("Analyze the Image", type="secondary")
44
-
45
- # # Check if an image has been uploaded, if the API key is available, and if the button has been pressed
46
- # if uploaded_file is not None and analyze_button:
47
-
48
- # with st.spinner("Analyzing the image ..."):
49
- # # Encode the image
50
- # base64_image = encode_image(uploaded_file)
51
-
52
- # # Optimized prompt for additional clarity and detail
53
- # prompt_text = (
54
- # "As an expert in image accessibility and alternative text, succinctly describe the image provided in less than 125 characters. "
55
- # "Provide a brief description that conveys the essential information conveyed by the image in three or fewer clear and concise sentences for use as alt text."
56
- # "Skip phrases like 'image of' or 'picture of.'"
57
- # "Your description should form a clear, well-structured, and factual paragraph that avoids bullet points, focusing on creating a seamless narrative that serves as effective alternative text for accessibility purposes."
58
- # )
59
-
60
  import streamlit as st
61
  import base64
62
  import openai
@@ -88,7 +29,7 @@ if uploaded_file:
88
  st.image(uploaded_file, caption=uploaded_file.name, width=image_width, use_column_width=False)
89
 
90
  # Toggle for showing additional details input
91
- show_details = st.toggle("Optional: Add details about the image. ", value=False)
92
 
93
  # Toggle for modifying the prompt for complex images
94
  complex_image = st.toggle("Is this a complex image? ", value=False)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
  import base64
3
  import openai
 
29
  st.image(uploaded_file, caption=uploaded_file.name, width=image_width, use_column_width=False)
30
 
31
  # Toggle for showing additional details input
32
+ show_details = st.toggle("Add details about the image. ", value=False)
33
 
34
  # Toggle for modifying the prompt for complex images
35
  complex_image = st.toggle("Is this a complex image? ", value=False)