PrakhAI commited on
Commit
54a56f6
·
1 Parent(s): a64727a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -37,7 +37,11 @@ if 'generate' in st.session_state:
37
  latents = sample_latent(ROWS * COLUMNS, jax.random.PRNGKey(unique_id))
38
  previous = st.session_state['generate']
39
  if previous is not None:
40
- latents = np.repeat([previous], repeats=16, axis=0) + 0.25 * latents
 
 
 
 
41
  (g_out128, _, _, _, _, _) = generator.apply({'params': g_state['params'], 'batch_stats': g_state['batch_stats']}, latents, training=False)
42
  img = np.array(to_img(g_out128))
43
  for row in range(ROWS):
@@ -46,4 +50,4 @@ if 'generate' in st.session_state:
46
  with col:
47
  idx = row*COLUMNS + col_idx
48
  st.image(Image.fromarray(img[idx]))
49
- st.button(label="Generate similar", key="%d_%d" % (unique_id, idx), on_click=set_latent, args=(latents[idx],))
 
37
  latents = sample_latent(ROWS * COLUMNS, jax.random.PRNGKey(unique_id))
38
  previous = st.session_state['generate']
39
  if previous is not None:
40
+ if 'similarity' not in st.session_state:
41
+ st.session_state['similarity'] = 0.25
42
+ similarity = st.number_input(label="Similarity (for \"Generate Similar\"", min_value=0.01, max_value=1.0, value=st.session_state['similarity'])
43
+ st.session_state['similarity'] = similarity
44
+ latents = np.repeat([previous], repeats=16, axis=0) + similarity * latents
45
  (g_out128, _, _, _, _, _) = generator.apply({'params': g_state['params'], 'batch_stats': g_state['batch_stats']}, latents, training=False)
46
  img = np.array(to_img(g_out128))
47
  for row in range(ROWS):
 
50
  with col:
51
  idx = row*COLUMNS + col_idx
52
  st.image(Image.fromarray(img[idx]))
53
+ st.button(label="Generate Similar", key="%d_%d" % (unique_id, idx), on_click=set_latent, args=(latents[idx],))