taesiri commited on
Commit
38b7a69
1 Parent(s): aa4c2be
Files changed (1) hide show
  1. app.py +9 -5
app.py CHANGED
@@ -76,9 +76,9 @@ if not JSON_DATASET_DIR.exists():
76
  JSON_DATASET_DIR.mkdir()
77
 
78
 
79
- def generate_data(type_of_nns):
80
  global NUMBER_OF_IMAGES
81
- # randomly pick NUMBER_OF_IMAGES from the dataset with type type_of_nns
82
  keys = list(all_data[type_of_nns].keys())
83
  sample_data = random.sample(keys, NUMBER_OF_IMAGES)
84
 
@@ -120,16 +120,18 @@ def load_sample(data, current_index):
120
 
121
  rounded_up_score = math.ceil(top_1_score)
122
  rounded_up_score = int(rounded_up_score)
123
- question = q_template.format(top_1.replace('_',' '), str(rounded_up_score), top_1.replace('_',' '))
 
 
124
 
125
  accept_reject = current_datapoint["Accept/Reject"]
126
 
127
  return image, top_1, rounded_up_score, question, accept_reject
128
 
129
 
130
- def preprocessing(data, type_of_nns, current_index, history, username):
131
  print("preprocessing")
132
- data = generate_data(type_of_nns)
133
  print("data generated")
134
 
135
  # append a random text to the username
@@ -312,6 +314,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
312
  choices=["top1", "topk"],
313
  value="top1",
314
  )
 
315
 
316
  prepare_btn = gr.Button(value="Start The Experiment")
317
 
@@ -351,6 +354,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
351
  current_index,
352
  history,
353
  username_textbox,
 
354
  ],
355
  outputs=[
356
  query_image,
 
76
  JSON_DATASET_DIR.mkdir()
77
 
78
 
79
+ def generate_data(type_of_nns, seed):
80
  global NUMBER_OF_IMAGES
81
+ random.seed(int(seed)) # Set the random seed
82
  keys = list(all_data[type_of_nns].keys())
83
  sample_data = random.sample(keys, NUMBER_OF_IMAGES)
84
 
 
120
 
121
  rounded_up_score = math.ceil(top_1_score)
122
  rounded_up_score = int(rounded_up_score)
123
+ question = q_template.format(
124
+ top_1.replace("_", " "), str(rounded_up_score), top_1.replace("_", " ")
125
+ )
126
 
127
  accept_reject = current_datapoint["Accept/Reject"]
128
 
129
  return image, top_1, rounded_up_score, question, accept_reject
130
 
131
 
132
+ def preprocessing(data, type_of_nns, current_index, history, username, seed):
133
  print("preprocessing")
134
+ data = generate_data(type_of_nns, seed) # Pass the seed here
135
  print("data generated")
136
 
137
  # append a random text to the username
 
314
  choices=["top1", "topk"],
315
  value="top1",
316
  )
317
+ random_seed_textbox = gr.Number(label="Random Seed", value="0")
318
 
319
  prepare_btn = gr.Button(value="Start The Experiment")
320
 
 
354
  current_index,
355
  history,
356
  username_textbox,
357
+ random_seed_textbox,
358
  ],
359
  outputs=[
360
  query_image,