kokuma commited on
Commit
353f0f6
·
verified ·
1 Parent(s): 69b1f8d

Limit to 2 options

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -111,7 +111,7 @@ def prepare(raw_idx, lang, text_embeddings, class_order, randomize_images):
111
  return prepare(raw_idx, lang, text_embeddings, class_order, randomize_images)
112
 
113
  similarity = (text_embeddings @ image_features.cpu().numpy().T).squeeze()
114
- choices = np.argsort(similarity)[-4:].tolist()
115
  else:
116
  choices = list(reversed(precomputed_results[lang][idx][img_idx])) # precomputing script uses torch.topk which sorts in reverse here
117
  if idx not in choices:
@@ -121,7 +121,7 @@ def prepare(raw_idx, lang, text_embeddings, class_order, randomize_images):
121
  numpy.random.shuffle(choices)
122
 
123
  choice_names = [class_labels[idx] for idx in choices]
124
- choice_values = [0, 1, 2, 3]
125
 
126
  model_choice_idx = choices.index(model_choice_idx)
127
  model_choice = [choice_names[model_choice_idx], choice_values[model_choice_idx]]
@@ -160,7 +160,7 @@ def reroll(raw_idx, lang, text_embeddings, class_order, randomize_images):
160
  return prepare(raw_idx, lang, text_embeddings, class_order, randomize_images)
161
 
162
  similarity = (text_embeddings @ image_features.cpu().numpy().T).squeeze()
163
- choices = np.argsort(similarity)[-4:].tolist()
164
  else:
165
  choices = list(reversed(precomputed_results[lang][idx][img_idx])) # precomputing script uses torch.topk which sorts in reverse here
166
  if idx not in choices:
@@ -170,7 +170,7 @@ def reroll(raw_idx, lang, text_embeddings, class_order, randomize_images):
170
  numpy.random.shuffle(choices)
171
 
172
  choice_names = [class_labels[idx] for idx in choices]
173
- choice_values = [0, 1, 2, 3]
174
 
175
  model_choice_idx = choices.index(model_choice_idx)
176
  model_choice = [choice_names[model_choice_idx], choice_values[model_choice_idx]]
 
111
  return prepare(raw_idx, lang, text_embeddings, class_order, randomize_images)
112
 
113
  similarity = (text_embeddings @ image_features.cpu().numpy().T).squeeze()
114
+ choices = np.argsort(similarity)[-2:].tolist()
115
  else:
116
  choices = list(reversed(precomputed_results[lang][idx][img_idx])) # precomputing script uses torch.topk which sorts in reverse here
117
  if idx not in choices:
 
121
  numpy.random.shuffle(choices)
122
 
123
  choice_names = [class_labels[idx] for idx in choices]
124
+ choice_values = [0, 1]
125
 
126
  model_choice_idx = choices.index(model_choice_idx)
127
  model_choice = [choice_names[model_choice_idx], choice_values[model_choice_idx]]
 
160
  return prepare(raw_idx, lang, text_embeddings, class_order, randomize_images)
161
 
162
  similarity = (text_embeddings @ image_features.cpu().numpy().T).squeeze()
163
+ choices = np.argsort(similarity)[-2:].tolist()
164
  else:
165
  choices = list(reversed(precomputed_results[lang][idx][img_idx])) # precomputing script uses torch.topk which sorts in reverse here
166
  if idx not in choices:
 
170
  numpy.random.shuffle(choices)
171
 
172
  choice_names = [class_labels[idx] for idx in choices]
173
+ choice_values = [0, 1]
174
 
175
  model_choice_idx = choices.index(model_choice_idx)
176
  model_choice = [choice_names[model_choice_idx], choice_values[model_choice_idx]]