rynmurdock commited on
Commit
babc6d9
1 Parent(s): a4f79b1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -7
app.py CHANGED
@@ -339,13 +339,9 @@ def choose(img, choice, calibrate_prompts, user_id, request: gr.Request):
339
  print('NSFW -- choice is disliked')
340
  choice = 0
341
 
342
- # TODO clean up
343
- old_d = prevs_df.loc[[p.split('/')[-1] in img for p in prevs_df['paths'].to_list()], 'user:rating'][0]
344
- old_d[user_id] = choice
345
- prevs_df.loc[[p.split('/')[-1] in img for p in prevs_df['paths'].to_list()], 'user:rating'][0] = old_d
346
- prevs_df.loc[[p.split('/')[-1] in img for p in prevs_df['paths'].to_list()], 'latest_user_to_rate'] = [user_id]
347
- print('full_df, prevs_df', prevs_df, prevs_df['latest_user_to_rate'])
348
-
349
  img, calibrate_prompts = next_image(calibrate_prompts, user_id)
350
  return img, calibrate_prompts
351
 
 
339
  print('NSFW -- choice is disliked')
340
  choice = 0
341
 
342
+ row_mask = [p.split('/')[-1] in img for p in prevs_df['paths'].to_list()]
343
+ old_d = prevs_df.loc[row_mask, 'user:rating'][0][user_id] = choice
344
+ prevs_df.loc[row_mask, 'latest_user_to_rate'] = [user_id]
 
 
 
 
345
  img, calibrate_prompts = next_image(calibrate_prompts, user_id)
346
  return img, calibrate_prompts
347