yuvaranianandhan24 commited on
Commit
6e7bcb5
Β·
verified Β·
1 Parent(s): 68e93b1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +52 -52
app.py CHANGED
@@ -80,69 +80,69 @@ def txt2img(text, style="realistic"):
80
 
81
  st.sidebar.title("Choose the task")
82
 
83
- # Streamlit web app main function
84
- def main():
85
- with st.sidebar.expander("Audio Story"):
86
-
87
- st.write(page_title="🎨 Image-to-Audio Story 🎧", page_icon="πŸ–ΌοΈ")
88
- st.title("Turn the Image into Audio Story")
89
-
90
- # Allows users to upload an image file
91
- uploaded_file = st.file_uploader("# πŸ“· Upload an image...", type=["jpg", "jpeg", "png"])
92
-
93
- # Parameters for LLM model (in the sidebar)
94
- #st.sidebar.markdown("# LLM Inference Configuration Parameters")
95
- #top_k = st.sidebar.number_input("Top-K", min_value=1, max_value=100, value=5)
96
- #top_p = st.sidebar.number_input("Top-P", min_value=0.0, max_value=1.0, value=0.8)
97
- #temperature = st.sidebar.number_input("Temperature", min_value=0.1, max_value=2.0, value=1.5)
98
-
99
- if uploaded_file is not None:
100
- # Reads and saves uploaded image file
101
- bytes_data = uploaded_file.read()
102
- with open("uploaded_image.jpg", "wb") as file:
103
- file.write(bytes_data)
104
 
105
- st.image(uploaded_file, caption='πŸ–ΌοΈ Uploaded Image', use_column_width=True)
106
-
107
- # Initiates AI processing and story generation
108
- with st.spinner("## πŸ€– AI is at Work! "):
109
- scenario = img2txt("uploaded_image.jpg") # Extracts text from the image
110
- story = generate_story(scenario, llm) # Generates a story based on the image text, LLM params
111
- txt2speech(story) # Converts the story to audio
112
-
113
- st.markdown("---")
114
- st.markdown("## πŸ“œ Image Caption")
115
- st.write(scenario)
116
-
117
- st.markdown("---")
118
- st.markdown("## πŸ“– Story")
119
- st.write(story)
120
-
121
- st.markdown("---")
122
- st.markdown("## 🎧 Audio Story")
123
- st.audio("audio_story.mp3")
124
 
125
- with st.sidebar.expander("Image Generator"):
126
- st.title("Stable Diffusion Image Generation")
127
- st.write("This app lets you generate images using Stable Diffusion with the Euler scheduler.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
128
 
129
- prompt = st.text_input("Enter your prompt:")
130
- image_style = st.selectbox("Style Selection", ["realistic", "cartoon", "watercolor"])
131
 
132
- if st.button("Generate Image"):
133
- if prompt:
134
  with st.spinner("Generating image..."):
135
- image = txt2img(prompt= prompt, style = image_style)
136
  st.image(image)
137
- else:
138
  st.error("Please enter a prompt.")
139
 
140
-
 
141
  st.title("Welcome to your Creative Canvas!")
142
  st.write("Use the tools in the sidebar to create audio stories and unique images.")
143
 
144
-
145
-
 
 
 
 
 
 
 
 
 
146
 
147
  if __name__ == '__main__':
148
  main()
 
80
 
81
  st.sidebar.title("Choose the task")
82
 
83
+ # Function for the Audio Story page
84
+ def audio_story_page():
85
+ st.title("🎨 Image-to-Audio Story 🎧")
86
+ st.write("Turn the Image into Audio Story")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
 
88
+ uploaded_file = st.file_uploader("Upload an image...", type=["jpg", "jpeg", "png"])
89
+
90
+ if uploaded_file is not None:
91
+ bytes_data = uploaded_file.read()
92
+ with open("uploaded_image.jpg", "wb") as file:
93
+ file.write(bytes_data)
 
 
 
 
 
 
 
 
 
 
 
 
 
94
 
95
+ st.image(uploaded_file, caption='πŸ–ΌοΈ Uploaded Image', use_column_width=True)
96
+
97
+ with st.spinner("AI is at Work!"):
98
+ scenario = img2txt("uploaded_image.jpg")
99
+ story = generate_story(scenario, llm)
100
+ txt2speech(story)
101
+
102
+ st.markdown("---")
103
+ st.markdown("## πŸ“œ Image Caption")
104
+ st.write(scenario)
105
+
106
+ st.markdown("---")
107
+ st.markdown("## πŸ“– Story")
108
+ st.write(story)
109
+
110
+ st.markdown("---")
111
+ st.markdown("## 🎧 Audio Story")
112
+ st.audio("audio_story.mp3")
113
+
114
+ # Function for the Image Generator page
115
+ def image_generator_page():
116
+ st.title("Stable Diffusion Image Generation")
117
+ st.write("This app lets you generate images using Stable Diffusion with the Euler scheduler.")
118
 
119
+ prompt = st.text_input("Enter your prompt:")
120
+ image_style = st.selectbox("Style Selection", ["realistic", "cartoon", "watercolor"])
121
 
122
+ if st.button("Generate Image"):
123
+ if prompt:
124
  with st.spinner("Generating image..."):
125
+ image = txt2img(prompt=prompt, style=image_style)
126
  st.image(image)
127
+ else:
128
  st.error("Please enter a prompt.")
129
 
130
+ # Function for the Home page
131
+ def home_page():
132
  st.title("Welcome to your Creative Canvas!")
133
  st.write("Use the tools in the sidebar to create audio stories and unique images.")
134
 
135
+ # Streamlit web app main function
136
+ def main():
137
+ st.sidebar.title("Navigation")
138
+ selection = st.sidebar.radio("Go to", ["Home", "Audio Story", "Image Generator"])
139
+
140
+ if selection == "Home":
141
+ home_page()
142
+ elif selection == "Audio Story":
143
+ audio_story_page()
144
+ elif selection == "Image Generator":
145
+ image_generator_page()
146
 
147
  if __name__ == '__main__':
148
  main()