mfranzon commited on
Commit
b9336f7
·
1 Parent(s): 4fd608e

fix main with spinner

Browse files
Files changed (1) hide show
  1. main.py +12 -4
main.py CHANGED
@@ -50,14 +50,22 @@ if st.button('Submit'):
50
  if bg_image:
51
  img_back=Image.open(bg_image).convert('RGB').resize(img_size)
52
  comp_img = img_back
53
- if np.any(canvas_result.image_data):
54
  img_draw=Image.fromarray(canvas_result.image_data).convert('RGB').resize(img_size)
55
  comp_img = img_draw
56
- if bg_image and np.any(canvas_result.image_data):
 
 
57
  comp_img = Image.new("RGB", img_size)
58
  comp_img = Image.blend(img_draw, img_back, alpha=0.5)
59
-
60
- images = pipe_image(prompt=prompt,
 
 
 
 
 
 
61
  init_image=comp_img,
62
  strength=strength)
63
  for image in images:
 
50
  if bg_image:
51
  img_back=Image.open(bg_image).convert('RGB').resize(img_size)
52
  comp_img = img_back
53
+ elif np.any(canvas_result.image_data):
54
  img_draw=Image.fromarray(canvas_result.image_data).convert('RGB').resize(img_size)
55
  comp_img = img_draw
56
+ elif bg_image and np.any(canvas_result.image_data):
57
+ img_back=Image.open(bg_image).convert('RGB').resize(img_size)
58
+ img_draw=Image.fromarray(canvas_result.image_data).convert('RGB').resize(img_size)
59
  comp_img = Image.new("RGB", img_size)
60
  comp_img = Image.blend(img_draw, img_back, alpha=0.5)
61
+ else:
62
+ raise "Upload an image or draw something"
63
+
64
+ if prompt is None:
65
+ raise "No prompt, no magic! :("
66
+
67
+ with st.spinner('Wait for it...'):
68
+ images = pipe_image(prompt=prompt,
69
  init_image=comp_img,
70
  strength=strength)
71
  for image in images: