Ricercar commited on
Commit
7ce7d8f
1 Parent(s): ec044c4

temporal display of prompt id

Browse files
Files changed (2) hide show
  1. pages/Gallery.py +5 -32
  2. pages/Ranking.py +0 -13
pages/Gallery.py CHANGED
@@ -87,11 +87,6 @@ class GalleryApp:
87
  edges = []
88
 
89
  for idx in items.index:
90
- # if items.loc[idx, 'modelVersion_id'] in st.session_state.selected_dict.get(items.loc[idx, 'prompt_id'], 0):
91
- # opacity = 0.2
92
- # else:
93
- # opacity = 1.0
94
-
95
  nodes.append(Node(id=items.loc[idx, 'image_id'],
96
  # label=str(items.loc[idx, 'model_name']),
97
  # title=f"model name: {items.loc[idx, 'model_name']}\nmodelVersion name: {items.loc[idx, 'modelVersion_name']}\nclip score: {items.loc[idx, 'clip_score']}\nmcos score: {items.loc[idx, 'mcos_score']}\npopularity: {items.loc[idx, 'model_download_count']}",
@@ -137,7 +132,7 @@ class GalleryApp:
137
  st.caption("`Source: Parti-prompts`")
138
 
139
  # show image metadata
140
- image_metadatas = ['prompt', 'negativePrompt', 'sampler', 'cfgScale', 'size', 'seed']
141
  for key in image_metadatas:
142
  label = ' '.join(key.split('_')).capitalize()
143
  st.write(f"**{label}**")
@@ -286,14 +281,6 @@ class GalleryApp:
286
 
287
  if has_selection:
288
  checkout = st.button('Check out selections ➡️', use_container_width=True, type='primary', on_click=self.switch_to_checkout, args=(tag, selected_prompt))
289
- # if checkout:
290
- # # add focus to session state
291
- # st.session_state.gallery_focus['tag'] = tag
292
- # st.session_state.gallery_focus['prompt'] = selected_prompt
293
- #
294
- # st.session_state.gallery_state = 'check out'
295
- # # print(st.session_state.gallery_state)
296
- # st.rerun()
297
  else:
298
  st.button(':orange[👇 **Select images you like below**]', disabled=True, use_container_width=True)
299
  try:
@@ -326,10 +313,6 @@ class GalleryApp:
326
 
327
  def graph_mode(self, prompt_id, items):
328
  graph_cols = st.columns([3, 1])
329
- # prompt = st.chat_input(f"Selected model version ids: {str(st.session_state.selected_dict.get(prompt_id, []))}",
330
- # disabled=False, key=f'{prompt_id}')
331
- # if prompt:
332
- # switch_page("ranking")
333
 
334
  with graph_cols[0]:
335
  st.caption(
@@ -378,6 +361,7 @@ class GalleryApp:
378
  # checked = True
379
  # else:
380
  # checked = False
 
381
  selection_control_button = st.empty()
382
  report_control_button = st.empty()
383
 
@@ -390,7 +374,6 @@ class GalleryApp:
390
  self.image_selection_control(item['tag'], item['prompt'], item['prompt_id'],
391
  modelVersion_id,
392
  'select')
393
- # st.toast('Image selected.', icon='👍')
394
 
395
  if image_status == 'select' or image_status == 'reselect' or image_status is None:
396
  # deselect = st.button('Deselect', key=f'select_{item["prompt_id"]}_{item["modelVersion_id"]}', use_container_width=True)
@@ -406,6 +389,7 @@ class GalleryApp:
406
  report = report_control_button.form_submit_button('⚠️Report', use_container_width=True, type='secondary',
407
  on_click=self.image_selection_control, args=(
408
  item['tag'], item['prompt'], item['prompt_id'], item['modelVersion_id'], 'report'))
 
409
  # st.write(item)
410
  # infos = ['model_name', 'modelVersion_name', 'model_download_count', 'clip_score', 'mcos_score',
411
  # 'nsfw_score']
@@ -419,15 +403,7 @@ class GalleryApp:
419
  st.info('You can click on and select an image.')
420
 
421
  def image_selection_control(self, tag, prompt, prompt_id, modelVersion_id, operation:['select', 'reselect', 'deselect','report']):
422
- self.remove_ranking_states(prompt_id)
423
-
424
- # # update the status of the lastest clicktime
425
- # query = "UPDATE gallery_clicks SET status= '{}' " \
426
- # "WHERE username = '{}' AND timestamp = '{}' AND prompt_id = '{}' AND modelVersion_id = {} AND clicktime = " \
427
- # "(SELECT MAX(clicktime) WHERE username = '{}' AND timestamp = '{}' AND prompt_id = '{}' AND modelVersion_id = {}" \
428
- # .format(operation,
429
- # st.session_state.user_id[0], st.session_state.user_id[1], prompt_id, modelVersion_id,
430
- # st.session_state.user_id[0], st.session_state.user_id[1], prompt_id, modelVersion_id)
431
 
432
  if operation == 'select' or operation == 'reselect':
433
  st.session_state.selected_dict[prompt_id].append(modelVersion_id)
@@ -516,6 +492,7 @@ class GalleryApp:
516
  proceed = st.button('Proceed ➡️', key=f'checkout_proceed_{prompt_id}', use_container_width=True,
517
  type='primary', disabled=st.session_state.edit_state)
518
  if proceed:
 
519
  st.session_state.gallery_focus['tag'] = tag
520
  st.session_state.gallery_focus['prompt'] = prompt
521
  st.session_state.gallery_state = 'graph'
@@ -631,11 +608,7 @@ def load_tsne_coordinates(items):
631
  # load tsne coordinates
632
  tsne_df = pd.read_parquet('./data/feats_tsne.parquet')
633
 
634
- # print(tsne_df['modelVersion_id'].dtype)
635
-
636
- # print('before merge:', items)
637
  items = items.merge(tsne_df, on=['modelVersion_id', 'prompt_id'], how='left')
638
- # print('after merge:', items)
639
  return items
640
 
641
 
 
87
  edges = []
88
 
89
  for idx in items.index:
 
 
 
 
 
90
  nodes.append(Node(id=items.loc[idx, 'image_id'],
91
  # label=str(items.loc[idx, 'model_name']),
92
  # title=f"model name: {items.loc[idx, 'model_name']}\nmodelVersion name: {items.loc[idx, 'modelVersion_name']}\nclip score: {items.loc[idx, 'clip_score']}\nmcos score: {items.loc[idx, 'mcos_score']}\npopularity: {items.loc[idx, 'model_download_count']}",
 
132
  st.caption("`Source: Parti-prompts`")
133
 
134
  # show image metadata
135
+ image_metadatas = ['prompt_id', 'prompt', 'negativePrompt', 'sampler', 'cfgScale', 'size', 'seed']
136
  for key in image_metadatas:
137
  label = ' '.join(key.split('_')).capitalize()
138
  st.write(f"**{label}**")
 
281
 
282
  if has_selection:
283
  checkout = st.button('Check out selections ➡️', use_container_width=True, type='primary', on_click=self.switch_to_checkout, args=(tag, selected_prompt))
 
 
 
 
 
 
 
 
284
  else:
285
  st.button(':orange[👇 **Select images you like below**]', disabled=True, use_container_width=True)
286
  try:
 
313
 
314
  def graph_mode(self, prompt_id, items):
315
  graph_cols = st.columns([3, 1])
 
 
 
 
316
 
317
  with graph_cols[0]:
318
  st.caption(
 
361
  # checked = True
362
  # else:
363
  # checked = False
364
+
365
  selection_control_button = st.empty()
366
  report_control_button = st.empty()
367
 
 
374
  self.image_selection_control(item['tag'], item['prompt'], item['prompt_id'],
375
  modelVersion_id,
376
  'select')
 
377
 
378
  if image_status == 'select' or image_status == 'reselect' or image_status is None:
379
  # deselect = st.button('Deselect', key=f'select_{item["prompt_id"]}_{item["modelVersion_id"]}', use_container_width=True)
 
389
  report = report_control_button.form_submit_button('⚠️Report', use_container_width=True, type='secondary',
390
  on_click=self.image_selection_control, args=(
391
  item['tag'], item['prompt'], item['prompt_id'], item['modelVersion_id'], 'report'))
392
+
393
  # st.write(item)
394
  # infos = ['model_name', 'modelVersion_name', 'model_download_count', 'clip_score', 'mcos_score',
395
  # 'nsfw_score']
 
403
  st.info('You can click on and select an image.')
404
 
405
  def image_selection_control(self, tag, prompt, prompt_id, modelVersion_id, operation:['select', 'reselect', 'deselect','report']):
406
+ # self.remove_ranking_states(prompt_id)
 
 
 
 
 
 
 
 
407
 
408
  if operation == 'select' or operation == 'reselect':
409
  st.session_state.selected_dict[prompt_id].append(modelVersion_id)
 
492
  proceed = st.button('Proceed ➡️', key=f'checkout_proceed_{prompt_id}', use_container_width=True,
493
  type='primary', disabled=st.session_state.edit_state)
494
  if proceed:
495
+ self.remove_ranking_states(prompt_id)
496
  st.session_state.gallery_focus['tag'] = tag
497
  st.session_state.gallery_focus['prompt'] = prompt
498
  st.session_state.gallery_state = 'graph'
 
608
  # load tsne coordinates
609
  tsne_df = pd.read_parquet('./data/feats_tsne.parquet')
610
 
 
 
 
611
  items = items.merge(tsne_df, on=['modelVersion_id', 'prompt_id'], how='left')
 
612
  return items
613
 
614
 
pages/Ranking.py CHANGED
@@ -420,19 +420,6 @@ class RankingApp:
420
  elif st.session_state.assigned_rank_mode == 'Battle':
421
  st.session_state.pointer[prompt_id] = {'left': 0, 'right': 1}
422
 
423
- # def connect_to_db():
424
- # conn = pymysql.connect(
425
- # host=os.environ.get('RANKING_DB_HOST'),
426
- # port=3306,
427
- # database='myRanking',
428
- # user=os.environ.get('RANKING_DB_USER'),
429
- # password=os.environ.get('RANKING_DB_PASSWORD'),
430
- # charset='utf8mb4',
431
- # cursorclass=pymysql.cursors.DictCursor
432
- # )
433
- #
434
- # return conn
435
-
436
 
437
  if __name__ == "__main__":
438
  st.set_page_config(page_title="Personal Image Ranking", page_icon="🎖️️", layout="wide")
 
420
  elif st.session_state.assigned_rank_mode == 'Battle':
421
  st.session_state.pointer[prompt_id] = {'left': 0, 'right': 1}
422
 
 
 
 
 
 
 
 
 
 
 
 
 
 
423
 
424
  if __name__ == "__main__":
425
  st.set_page_config(page_title="Personal Image Ranking", page_icon="🎖️️", layout="wide")