rynmurdock commited on
Commit
67ec952
1 Parent(s): c7b36a6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -0
app.py CHANGED
@@ -114,6 +114,13 @@ def next_image(embs, ys, calibrate_prompts):
114
  # sample a .8 of rated embeddings for some stochasticity, or at least two embeddings.
115
  n_to_choose = max(int(len(embs)*.8), 2)
116
  indices = random.sample(range(len(embs)), n_to_choose)
 
 
 
 
 
 
 
117
 
118
  # also add the latest 0 and the latest 1
119
  has_0 = False
 
114
  # sample a .8 of rated embeddings for some stochasticity, or at least two embeddings.
115
  n_to_choose = max(int(len(embs)*.8), 2)
116
  indices = random.sample(range(len(embs)), n_to_choose)
117
+
118
+ # we may have just encountered a rare multi-threading diffusers issue (https://github.com/huggingface/diffusers/issues/5749);
119
+ # this ends up adding a rating but losing an embedding, it seems.
120
+ # let's take off a rating if so to continue without indexing errors.
121
+ if len(ys) > len(embs):
122
+ print('ys are longer than embs; popping latest rating')
123
+ ys.pop(-1)
124
 
125
  # also add the latest 0 and the latest 1
126
  has_0 = False