Mairaaa commited on
Commit
e27303d
·
verified ·
1 Parent(s): 74d4e67

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -1
app.py CHANGED
@@ -52,6 +52,9 @@ st.write("Generate images based on rough sketches, text input, or both.")
52
 
53
  option = st.radio("Select Input Type", ("Sketch", "Text", "Both"))
54
 
 
 
 
55
  if option in ["Sketch", "Both"]:
56
  sketch_file = st.file_uploader("Upload a Sketch", type=["png", "jpg", "jpeg"])
57
 
@@ -59,14 +62,18 @@ if option in ["Text", "Both"]:
59
  text_input = st.text_input("Enter Text Prompt", placeholder="Describe the image you want to generate")
60
 
61
  if st.button("Generate"):
 
 
 
62
  if option == "Sketch" and not sketch_file:
63
  st.error("Please upload a sketch.")
64
  elif option == "Text" and not text_input:
65
  st.error("Please provide text input.")
 
 
66
  else:
67
  # Generate images based on user input
68
  with st.spinner("Generating images..."):
69
- sketches = BytesIO(sketch_file.read()) if sketch_file else None
70
  images = generate_images(pipe, text_input=text_input, sketch=sketches)
71
 
72
  if images:
 
52
 
53
  option = st.radio("Select Input Type", ("Sketch", "Text", "Both"))
54
 
55
+ sketch_file = None
56
+ text_input = None
57
+
58
  if option in ["Sketch", "Both"]:
59
  sketch_file = st.file_uploader("Upload a Sketch", type=["png", "jpg", "jpeg"])
60
 
 
62
  text_input = st.text_input("Enter Text Prompt", placeholder="Describe the image you want to generate")
63
 
64
  if st.button("Generate"):
65
+ # Ensure text_input and sketches are handled properly
66
+ sketches = BytesIO(sketch_file.read()) if sketch_file else None
67
+
68
  if option == "Sketch" and not sketch_file:
69
  st.error("Please upload a sketch.")
70
  elif option == "Text" and not text_input:
71
  st.error("Please provide text input.")
72
+ elif option == "Both" and not (sketch_file or text_input):
73
+ st.error("Please provide both a sketch and a text prompt.")
74
  else:
75
  # Generate images based on user input
76
  with st.spinner("Generating images..."):
 
77
  images = generate_images(pipe, text_input=text_input, sketch=sketches)
78
 
79
  if images: