rynmurdock commited on
Commit
07db9b5
·
verified ·
1 Parent(s): 2dbb419

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -224,6 +224,7 @@ def pluck_img(user_id, user_emb):
224
  not_rated_rows = prevs_df[[i[1]['user:rating'].get(user_id, None) == None for i in prevs_df.iterrows()]]
225
  rated_rows = prevs_df[[i[1]['user:rating'].get(user_id, None) != None for i in prevs_df.iterrows()]]
226
  time.sleep(.01)
 
227
  # TODO optimize this lol
228
  best_sim = -100000
229
  for i in not_rated_rows.iterrows():
@@ -246,12 +247,14 @@ def background_next_image():
246
  not_rated_rows = prevs_df[[i[1]['user:rating'] == {' ': ' '} for i in prevs_df.iterrows()]]
247
  rated_rows = prevs_df[[i[1]['user:rating'] != {' ': ' '} for i in prevs_df.iterrows()]]
248
  time.sleep(.01)
 
249
 
250
  latest_user_id = rated_rows.iloc[-1]['latest_user_to_rate']
251
  rated_rows = prevs_df[[i[1]['user:rating'].get(latest_user_id, None) is not None for i in prevs_df.iterrows()]]
252
  while len(rated_rows) < 4:
253
  rated_rows = prevs_df[[i[1]['user:rating'].get(latest_user_id, None) is not None for i in prevs_df.iterrows()]]
254
  time.sleep(.01)
 
255
 
256
  print(latest_user_id)
257
  embs, ys = pluck_embs_ys(latest_user_id)
@@ -284,6 +287,7 @@ def pluck_embs_ys(user_id):
284
  not_rated_rows = prevs_df[[i[1]['user:rating'].get(user_id, None) == None for i in prevs_df.iterrows()]]
285
  rated_rows = prevs_df[[i[1]['user:rating'].get(user_id, None) != None for i in prevs_df.iterrows()]]
286
  time.sleep(.01)
 
287
 
288
  embs = rated_rows['embeddings'].to_list()
289
  ys = [i[user_id] for i in rated_rows['user:rating'].to_list()]
@@ -348,7 +352,7 @@ def choose(img, choice, calibrate_prompts, user_id, request: gr.Request):
348
  choice = 0
349
 
350
  row_mask = [p.split('/')[-1] in img for p in prevs_df['paths'].to_list()]
351
- old_d = prevs_df.loc[row_mask, 'user:rating'][0][user_id] = choice
352
  prevs_df.loc[row_mask, 'latest_user_to_rate'] = [user_id]
353
  img, calibrate_prompts = next_image(calibrate_prompts, user_id)
354
  return img, calibrate_prompts
 
224
  not_rated_rows = prevs_df[[i[1]['user:rating'].get(user_id, None) == None for i in prevs_df.iterrows()]]
225
  rated_rows = prevs_df[[i[1]['user:rating'].get(user_id, None) != None for i in prevs_df.iterrows()]]
226
  time.sleep(.01)
227
+ print('current user has rated all rows')
228
  # TODO optimize this lol
229
  best_sim = -100000
230
  for i in not_rated_rows.iterrows():
 
247
  not_rated_rows = prevs_df[[i[1]['user:rating'] == {' ': ' '} for i in prevs_df.iterrows()]]
248
  rated_rows = prevs_df[[i[1]['user:rating'] != {' ': ' '} for i in prevs_df.iterrows()]]
249
  time.sleep(.01)
250
+ print('all users have 8 or more rows left to rate')
251
 
252
  latest_user_id = rated_rows.iloc[-1]['latest_user_to_rate']
253
  rated_rows = prevs_df[[i[1]['user:rating'].get(latest_user_id, None) is not None for i in prevs_df.iterrows()]]
254
  while len(rated_rows) < 4:
255
  rated_rows = prevs_df[[i[1]['user:rating'].get(latest_user_id, None) is not None for i in prevs_df.iterrows()]]
256
  time.sleep(.01)
257
+ print('latest user has < 4 rated_rows')
258
 
259
  print(latest_user_id)
260
  embs, ys = pluck_embs_ys(latest_user_id)
 
287
  not_rated_rows = prevs_df[[i[1]['user:rating'].get(user_id, None) == None for i in prevs_df.iterrows()]]
288
  rated_rows = prevs_df[[i[1]['user:rating'].get(user_id, None) != None for i in prevs_df.iterrows()]]
289
  time.sleep(.01)
290
+ print('current user has 0 not_rated_rows')
291
 
292
  embs = rated_rows['embeddings'].to_list()
293
  ys = [i[user_id] for i in rated_rows['user:rating'].to_list()]
 
352
  choice = 0
353
 
354
  row_mask = [p.split('/')[-1] in img for p in prevs_df['paths'].to_list()]
355
+ prevs_df.loc[row_mask, 'user:rating'][0][user_id] = choice
356
  prevs_df.loc[row_mask, 'latest_user_to_rate'] = [user_id]
357
  img, calibrate_prompts = next_image(calibrate_prompts, user_id)
358
  return img, calibrate_prompts