BertChristiaens commited on
Commit
2ea3bd8
1 Parent(s): d47ae93

add segmentation maps

Browse files
Files changed (1) hide show
  1. app.py +13 -0
app.py CHANGED
@@ -151,6 +151,19 @@ def make_editing_canvas(canvas_color, brush, _reset_state, generation_mode, pain
151
  canvas = st_canvas(
152
  **canvas_dict,
153
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
154
 
155
  if st.button("generate image", key='generate_button'):
156
  image = get_image()
 
151
  canvas = st_canvas(
152
  **canvas_dict,
153
  )
154
+ if 'seg' not in st.session_state:
155
+ image = get_image()
156
+ print("Preparing image segmentation")
157
+ real_seg = segment_image(Image.fromarray(image))
158
+ st.session_state['seg'] = real_seg
159
+ # get unique RGB colors from this segmentation map
160
+ unique_colors = np.unique(real_seg.reshape(-1, real_seg.shape[2]), axis=0)
161
+ st.session_state['unique_colors'] = unique_colors
162
+ # multiselect to choose multiple colors
163
+ chosen_colors = st.multiselect(
164
+ "Choose colors", list(unique_colors), format_func=map_colors, key='chosen_colors'
165
+ )
166
+ print(chosen_colors)
167
 
168
  if st.button("generate image", key='generate_button'):
169
  image = get_image()