ludusc commited on
Commit
82608be
1 Parent(s): c63daa2

prjection as state id

Browse files
pages/1_Omniart_Disentanglement.py CHANGED
@@ -46,6 +46,8 @@ with open(concepts) as f:
46
 
47
  if 'image_id' not in st.session_state:
48
  st.session_state.image_id = 0
 
 
49
  if 'concept_id' not in st.session_state:
50
  st.session_state.concept_id = 'Abstract'
51
  if 'space_id' not in st.session_state:
@@ -132,10 +134,10 @@ with input_col_2:
132
  image_id = random.randint(0, 50000)
133
  st.session_state.image_id = image_id
134
  chosen_image_id_input.number_input('Image ID:', format='%d', step=1, value=st.session_state.image_id)
135
- projection = False
136
 
137
  if projection_id:
138
- projection = True
139
 
140
  if choose_image_button:
141
  image_id = int(image_id)
@@ -167,7 +169,7 @@ if st.session_state.space_id == 'Z':
167
  else:
168
  original_image_vec = annotations['w_vectors'][st.session_state.image_id]
169
 
170
- if projection:
171
  original_image_vec = original_image_vec - np.dot(original_image_vec.T, separation_vector) * separation_vector
172
 
173
  img = generate_original_image(original_image_vec, model, latent_space=st.session_state.space_id)
 
46
 
47
  if 'image_id' not in st.session_state:
48
  st.session_state.image_id = 0
49
+ if 'projection' not in st.session_state:
50
+ st.session_state.projection = False
51
  if 'concept_id' not in st.session_state:
52
  st.session_state.concept_id = 'Abstract'
53
  if 'space_id' not in st.session_state:
 
134
  image_id = random.randint(0, 50000)
135
  st.session_state.image_id = image_id
136
  chosen_image_id_input.number_input('Image ID:', format='%d', step=1, value=st.session_state.image_id)
137
+ st.session_state.projection = False
138
 
139
  if projection_id:
140
+ st.session_state.projection = True
141
 
142
  if choose_image_button:
143
  image_id = int(image_id)
 
169
  else:
170
  original_image_vec = annotations['w_vectors'][st.session_state.image_id]
171
 
172
+ if st.session_state.projection:
173
  original_image_vec = original_image_vec - np.dot(original_image_vec.T, separation_vector) * separation_vector
174
 
175
  img = generate_original_image(original_image_vec, model, latent_space=st.session_state.space_id)
view_omniart_data.ipynb ADDED
File without changes