import streamlit as st from functions import generate_controlnet_image, generate_image, generate_video from choices import text_to_image_models,controlnet_models,image_to_video_models def text_to_image(input_text, selected_model): result = generate_image(selected_model,input_text) return result def image_to_image(input_text,input_image, selected_model, selected_algorithm): return "path_to_image_to_image_result.jpg" def image_to_video(input_text,input_image, selected_model1, selected_model2, selected_algorithm): return "path_to_image_to_video_result.jpg" def main(): st.title("Image Processing Options") processing_option = st.selectbox("Select Processing Option", ["Text to Image", "Image to Image", "Image to Video"]) if processing_option == "Text to Image": input_text = st.text_area("Enter Text for Image") selected_model = st.selectbox("Select Model", text_to_image_models) if st.button("Generate Image"): result_image_path = text_to_image(input_text, selected_model) st.image(result_image_path, caption="Result Image", use_column_width=True) elif processing_option == "Image to Image" or processing_option == "Image to Video": input_text = st.text_area("Enter Text for Image") input_image = st.file_uploader("Upload Input Image", type=["jpg", "png"]) selected_algorithm = st.selectbox("Select Algorithm", ["Algorithm 1", "Algorithm 2"]) if processing_option == "Image to Image": selected_model = st.selectbox("Select Model", controlnet_models) elif processing_option == "Image to Video": selected_model = st.selectbox("Select Model", image_to_video_models) if st.button("Process"): if input_image is not None: if processing_option == "Image to Image": result_image_path = image_to_image(input_text,input_image, selected_model, selected_algorithm) elif processing_option == "Image to Video": result_image_path = image_to_video(input_text,input_image, selected_model, selected_algorithm) st.image(result_image_path, caption="Result Image", use_column_width=True) else: st.warning("Please upload an input image.") if __name__ == "__main__": main()