import gradio as gr # Function to handle size selection def handle_size(selected_size): """ Returns a message based on the selected size ratio. """ return f"You have selected the size ratio: {selected_size}" # Function to handle theme selection def handle_theme(selected_theme): """ Returns a message based on the selected theme. """ return f"You have selected the theme: {selected_theme}" # Function to reset selections to default values def reset_selections(): """ Resets the size ratio and theme selections to their default values. """ return "16:9", "Light", "You have reset to default settings." # Create a Gradio Blocks interface with gr.Blocks() as demo: # Add a title to the app gr.Markdown("## Welcome to the FLUX Model App") # Create a row for layout with gr.Row(): # Add a dropdown for size selection size_dropdown = gr.Dropdown( choices=["1:3", "16:9", "4:3", "21:9"], label="Select Size Ratio", value="16:9" # Set a default value ) # Add a dropdown for theme selection theme_dropdown = gr.Dropdown( choices=["Light", "Dark"], label="Select Theme", value="Light" # Set a default value ) # Add a button to confirm selections submit_button = gr.Button("Submit") # Add a button to reset selections reset_button = gr.Button("Reset to Default") # Add a textbox to display the selected size size_output = gr.Textbox(label="Selected Size") # Add a textbox to display the selected theme theme_output = gr.Textbox(label="Selected Theme") # Add a textbox to display reset confirmation reset_output = gr.Textbox(label="Reset Confirmation") # Define the action when the submit button is clicked submit_button.click( fn=lambda size, theme: (handle_size(size), handle_theme(theme)), inputs=[size_dropdown, theme_dropdown], outputs=[size_output, theme_output] ) # Define the action when the reset button is clicked reset_button.click( fn=reset_selections, inputs=None, outputs=[size_dropdown, theme_dropdown, reset_output] ) # Load and launch the FLUX model gr.load("models/black-forest-labs/FLUX.1-dev").launch() # Launch the Gradio app demo.launch()