Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -102,8 +102,8 @@ def main():
|
|
| 102 |
st.header("Generate image with ControllNet")
|
| 103 |
with st.sidebar:
|
| 104 |
st_lottie(lottie_penguin, height=200)
|
| 105 |
-
choose = option_menu("Generate image", ["Upload", "Canvas"
|
| 106 |
-
icons=['cloud-upload', 'file-plus'
|
| 107 |
menu_icon="infinity", default_index=0,
|
| 108 |
styles={
|
| 109 |
"container": {"padding": ".0rem", "font-size": "14px"},
|
|
@@ -167,11 +167,13 @@ def main():
|
|
| 167 |
|
| 168 |
elif choose == 'Canvas':
|
| 169 |
with st.form(key='canvas_generate_form'):
|
|
|
|
| 170 |
# Specify canvas parameters in application
|
| 171 |
stroke_width = st.sidebar.slider("Stroke width: ", 1, 25, 3)
|
| 172 |
stroke_color = st.sidebar.color_picker("Stroke color hex: ")
|
| 173 |
bg_color = st.sidebar.color_picker("Background color hex: ", "#eee")
|
| 174 |
realtime_update = st.sidebar.checkbox("Update in realtime", True)
|
|
|
|
| 175 |
# Create a canvas component
|
| 176 |
col31, col32 = st.columns(2)
|
| 177 |
with col31:
|
|
@@ -209,7 +211,7 @@ def main():
|
|
| 209 |
n_prompt = st.text_input(label="Negative Prompt",
|
| 210 |
value='longbody, lowres, bad anatomy, bad hands, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality')
|
| 211 |
|
| 212 |
-
#
|
| 213 |
generate_button = st.form_submit_button(label='Generate Image')
|
| 214 |
if generate_button:
|
| 215 |
if canvas_result.image_data is not None:
|
|
@@ -219,19 +221,18 @@ def main():
|
|
| 219 |
H, W, C = input_image.shape
|
| 220 |
output_image = cv2.resize(results[0], (W, H), interpolation=cv2.INTER_AREA)
|
| 221 |
col32.image(output_image, channels='RGB', width=None, clamp=True, caption='Generated image')
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
|
| 236 |
if __name__ == '__main__':
|
| 237 |
main()
|
|
|
|
| 102 |
st.header("Generate image with ControllNet")
|
| 103 |
with st.sidebar:
|
| 104 |
st_lottie(lottie_penguin, height=200)
|
| 105 |
+
choose = option_menu("Generate image", ["Upload", "Canvas"],
|
| 106 |
+
icons=['cloud-upload', 'file-plus'],
|
| 107 |
menu_icon="infinity", default_index=0,
|
| 108 |
styles={
|
| 109 |
"container": {"padding": ".0rem", "font-size": "14px"},
|
|
|
|
| 167 |
|
| 168 |
elif choose == 'Canvas':
|
| 169 |
with st.form(key='canvas_generate_form'):
|
| 170 |
+
|
| 171 |
# Specify canvas parameters in application
|
| 172 |
stroke_width = st.sidebar.slider("Stroke width: ", 1, 25, 3)
|
| 173 |
stroke_color = st.sidebar.color_picker("Stroke color hex: ")
|
| 174 |
bg_color = st.sidebar.color_picker("Background color hex: ", "#eee")
|
| 175 |
realtime_update = st.sidebar.checkbox("Update in realtime", True)
|
| 176 |
+
|
| 177 |
# Create a canvas component
|
| 178 |
col31, col32 = st.columns(2)
|
| 179 |
with col31:
|
|
|
|
| 211 |
n_prompt = st.text_input(label="Negative Prompt",
|
| 212 |
value='longbody, lowres, bad anatomy, bad hands, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality')
|
| 213 |
|
| 214 |
+
# Generate image from canvas
|
| 215 |
generate_button = st.form_submit_button(label='Generate Image')
|
| 216 |
if generate_button:
|
| 217 |
if canvas_result.image_data is not None:
|
|
|
|
| 221 |
H, W, C = input_image.shape
|
| 222 |
output_image = cv2.resize(results[0], (W, H), interpolation=cv2.INTER_AREA)
|
| 223 |
col32.image(output_image, channels='RGB', width=None, clamp=True, caption='Generated image')
|
| 224 |
+
|
| 225 |
+
# Image gallery
|
| 226 |
+
with st.expander('Image gallery', expanded=True):
|
| 227 |
+
col01, col02, = st.columns(2)
|
| 228 |
+
with col01:
|
| 229 |
+
st.image('demo/example_1.jpg', caption="Sport car")
|
| 230 |
+
st.image('demo/example_2.jpg', caption="Dog house")
|
| 231 |
+
st.image('demo/example_3.jpg', caption="Guitar")
|
| 232 |
+
with col02:
|
| 233 |
+
st.image('demo/example_4.jpg', caption="Sport car")
|
| 234 |
+
st.image('demo/example_5.jpg', caption="Dog house")
|
| 235 |
+
st.image('demo/example_6.jpg', caption="Guitar")
|
|
|
|
| 236 |
|
| 237 |
if __name__ == '__main__':
|
| 238 |
main()
|