File size: 3,143 Bytes
efbc792
a1322b1
acb8c94
4a39ad4
efbc792
 
4a39ad4
efbc792
4a39ad4
efbc792
4a39ad4
efbc792
 
4a39ad4
 
a1322b1
4a39ad4
 
 
 
 
 
 
efbc792
4a39ad4
 
 
 
 
 
 
 
 
efbc792
4a39ad4
 
 
 
 
efbc792
4a39ad4
 
 
 
 
 
 
 
efbc792
 
4a39ad4
efbc792
4a39ad4
a1322b1
efbc792
4a39ad4
a1322b1
 
efbc792
a1322b1
4a39ad4
 
aaa805e
acb8c94
4a39ad4
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import streamlit as st
import requests
import tempfile
import numpy as np

# Set page config
st.set_page_config(page_title='Image Generation', page_icon=':pizza:', layout='wide')

st.title('Pizza Image Generation')

# Initialize session state for storing user inputs
if 'dynamic_prompt' not in st.session_state:
    st.session_state['dynamic_prompt'] = ""
if 'image_data' not in st.session_state:
    st.session_state['image_data'] = None

# Define pizza options
pizza_names = ["Crispy Chicken", "Chicken Pesto", "Deluxe Pepperoni", "Truffle Mushroom",
               "Ultimate Cheese", "Spicy Veggie Ranch", "Classic Chicken Ranch",
               "BBQ Chicken Ranch", "Spicy Chicken Ranch", "Very Veggie",
               "Super Supreme", "Classic Pepperoni", "Margherita", "Cheeky Chicken",
               "Chicken Super Supreme", "Chicken BBQ Supreme", "Chicken Fajita",
               "Chicken Shawerma", "Other"]

pizza_sizes = ["Small", "Medium", "Large", "Extra Large"]

toppings_options = ["Arugula", "Bacon", "Basil", "Broccoli", "Cheese", "Chicken", "Corn", 
                    "Ham", "Mushroom", "Olives", "Onion", "Pepperoni", "Peppers", 
                    "Pineapple", "Tomatoes"]

bg_color_options = ['White', 'Black', 'Light Blue', 'Light Green', 'Light Yellow', 'Light Pink']

orientation_options = ["Top View", "Side View", "Lateral View"]

# UI Components for Pizza Preferences
with st.form(key='prompt_form'):
    # Pizza selection
    selected_pizza = st.selectbox("Choose a Pizza Type", pizza_names)
    selected_size = st.selectbox("Choose Pizza Size", pizza_sizes)
    
    # Toppings selection
    selected_toppings = st.multiselect("Choose Toppings", toppings_options, default=["Mushroom", "Tomatoes", "Onion"])

    # Additional customization
    additional_description = st.text_input("Enter additional descriptions (optional)")
    background_color = st.selectbox("Choose Background Color", bg_color_options)
    orientation = st.multiselect("Select Orientation", orientation_options, default=["Top View"])

    generate_prompt_button = st.form_submit_button(label='Generate Prompt')

# Processing user input to generate dynamic prompt
if generate_prompt_button:
    st.session_state['dynamic_prompt'] = f"A {selected_size} {selected_pizza} Pizza with {', '.join(selected_toppings)}. Additional description: {additional_description}. Background color: {background_color}. Orientation: {', '.join(orientation)}."
    st.write("Prompt:", st.session_state['dynamic_prompt'])

# Rest of your code for image generation and display...
with st.form(key='image_form'):
    generate_image_button = st.form_submit_button(label='Generate Image')

if generate_image_button and st.session_state['dynamic_prompt']:
    # Generate the image using your custom model
    # Assuming 'my_custom_model_generate_image' is a function that returns the image data
    st.session_state['image_data'] = (st.session_state['dynamic_prompt'])

    # Display the generated image if available
    if st.session_state['image_data'] is not None:
        st.image(st.session_state['image_data'], caption="Generated Image", use_column_width=True)