patrickvonplaten commited on
Commit
9eb3a05
β€’
1 Parent(s): 2d3a398

make style

Browse files
Files changed (2) hide show
  1. README.md +1 -1
  2. app.py +51 -17
README.md CHANGED
@@ -4,7 +4,7 @@ emoji: πŸ“Š
4
  colorFrom: blue
5
  colorTo: purple
6
  sdk: gradio
7
- sdk_version: 3.29.0
8
  app_file: app.py
9
  pinned: false
10
  license: apache-2.0
 
4
  colorFrom: blue
5
  colorTo: purple
6
  sdk: gradio
7
+ sdk_version: 3.41.0
8
  app_file: app.py
9
  pinned: false
10
  license: apache-2.0
app.py CHANGED
@@ -1,22 +1,30 @@
1
- from datasets import load_dataset
2
- from collections import Counter, defaultdict
3
- import pandas as pd
4
- from huggingface_hub import list_datasets
5
  import os
 
6
  import gradio as gr
 
 
 
 
 
 
 
 
 
 
 
7
 
8
  parti_prompt_results = []
9
  ORG = "diffusers-parti-prompts"
10
  SUBMISSIONS = {
11
- "sd-v1-5": None,
12
- "sd-v2-1": None,
13
- "if-v1-0": None,
14
  "karlo": None,
15
  }
16
  LINKS = {
17
- "sd-v1-5": "https://huggingface.co/runwayml/stable-diffusion-v1-5",
18
- "sd-v2-1": "https://huggingface.co/stabilityai/stable-diffusion-2-1",
19
- "if-v1-0": "https://huggingface.co/DeepFloyd/IF-I-XL-v1.0",
20
  "karlo": "https://huggingface.co/kakaobrain/karlo-v1-alpha",
21
  }
22
  MODEL_KEYS = "-".join(SUBMISSIONS.keys())
@@ -40,9 +48,26 @@ def load_submissions():
40
  total_submissions = 0
41
 
42
  for _id in relevant_ids:
43
- ds = load_dataset(_id)["train"]
 
 
 
 
 
 
 
44
  for result, image_id in zip(ds["result"], ds["id"]):
45
- if result not in submission_names:
 
 
 
 
 
 
 
 
 
 
46
  # Make sure that incorrect model names are not added
47
  continue
48
 
@@ -84,6 +109,10 @@ def get_dataframe_all():
84
  categories_frame = categories_frame.reset_index().rename(columns={'index': 'Category'})
85
  challenges_frame = challenges_frame.reset_index().rename(columns={'index': 'Challenge'})
86
 
 
 
 
 
87
  return total_submissions, main_frame, challenges_frame, categories_frame
88
 
89
  TITLE = "# Open Parti Prompts Leaderboard"
@@ -110,10 +139,10 @@ For more information of how the images were created, please refer to [Open Parti
110
  The community's answers are then stored and used in this space to give a human-preference-based comparison of the different models. \n\n
111
 
112
  Currently the leaderboard includes the following models:
113
- - [sd-v1-5](https://huggingface.co/runwayml/stable-diffusion-v1-5)
114
- - [sd-v2-1](https://huggingface.co/stabilityai/stable-diffusion-2-1)
115
- - [if-v1-0](https://huggingface.co/DeepFloyd/IF-I-XL-v1.0)
116
- - [karlo](https://huggingface.co/kakaobrain/karlo-v1-alpha) \n\n
117
 
118
  In the following you can see three result tables. The first shows the overall comparison of the 4 models. The score states,
119
  **the percentage at which images generated from the corresponding model are preferred over the image from all other models**. The second and third tables
@@ -175,6 +204,11 @@ with gr.Blocks() as demo:
175
 
176
  with gr.Row():
177
  refresh_button = gr.Button("Refresh")
178
- refresh_button.click(refresh, inputs=[], outputs=[num_submissions, main_dataframe, cat_dataframe, chal_dataframe])
 
 
 
 
 
179
 
180
  demo.launch()
 
 
 
 
 
1
  import os
2
+
3
  import gradio as gr
4
+ import pandas as pd
5
+
6
+ from apscheduler.schedulers.background import BackgroundScheduler
7
+ from collections import Counter, defaultdict
8
+ from datasets import load_dataset
9
+ import datasets
10
+ from huggingface_hub import HfApi, list_datasets
11
+
12
+ api = HfApi(token=os.environ.get("HF_TOKEN", None))
13
+ def restart_space():
14
+ api.restart_space(repo_id="OpenGenAI/parti-prompts-leaderboard")
15
 
16
  parti_prompt_results = []
17
  ORG = "diffusers-parti-prompts"
18
  SUBMISSIONS = {
19
+ "kand2": None,
20
+ "sdxl": None,
21
+ "wuerst": None,
22
  "karlo": None,
23
  }
24
  LINKS = {
25
+ "kand2": "https://huggingface.co/kandinsky-community/kandinsky-2-2-decoder",
26
+ "sdxl": "https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0",
27
+ "wuerst": "https://huggingface.co/warp-ai/wuerstchen",
28
  "karlo": "https://huggingface.co/kakaobrain/karlo-v1-alpha",
29
  }
30
  MODEL_KEYS = "-".join(SUBMISSIONS.keys())
 
48
  total_submissions = 0
49
 
50
  for _id in relevant_ids:
51
+ try:
52
+ ds = load_dataset(_id)["train"]
53
+ except:
54
+ # skip dataset
55
+ continue
56
+
57
+ all_results = []
58
+ all_ids = []
59
  for result, image_id in zip(ds["result"], ds["id"]):
60
+ all_result = result.split(",")
61
+
62
+ all_results += all_result
63
+ all_ids += (len(all_result) * [image_id])
64
+
65
+ for result, image_id in zip(all_results, all_ids):
66
+ if result == "":
67
+ print(f"{result} was not solved by any model.")
68
+
69
+ elif result not in submission_names:
70
+ import ipdb; ipdb.set_trace()
71
  # Make sure that incorrect model names are not added
72
  continue
73
 
 
109
  categories_frame = categories_frame.reset_index().rename(columns={'index': 'Category'})
110
  challenges_frame = challenges_frame.reset_index().rename(columns={'index': 'Challenge'})
111
 
112
+ main_frame = main_frame.rename(columns={"": "NOT SOLVED"})
113
+ categories_frame = categories_frame.rename(columns={"": "NOT SOLVED"})
114
+ challenges_frame = challenges_frame.rename(columns={"": "NOT SOLVED"})
115
+
116
  return total_submissions, main_frame, challenges_frame, categories_frame
117
 
118
  TITLE = "# Open Parti Prompts Leaderboard"
 
139
  The community's answers are then stored and used in this space to give a human-preference-based comparison of the different models. \n\n
140
 
141
  Currently the leaderboard includes the following models:
142
+ - [kand2](https://huggingface.co/kandinsky-community/kandinsky-2-2-decoder),
143
+ - [sdxl](https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0),
144
+ - [wuerst](https://huggingface.co/warp-ai/wuerstchen),
145
+ - [karlo](https://huggingface.co/kakaobrain/karlo-v1-alpha),
146
 
147
  In the following you can see three result tables. The first shows the overall comparison of the 4 models. The score states,
148
  **the percentage at which images generated from the corresponding model are preferred over the image from all other models**. The second and third tables
 
204
 
205
  with gr.Row():
206
  refresh_button = gr.Button("Refresh")
207
+ refresh_button.click(refresh, inputs=[], outputs=[num_submissions, main_dataframe, cat_dataframe, chal_dataframe])
208
+
209
+ # Restart space every 20 minutes
210
+ scheduler = BackgroundScheduler()
211
+ scheduler.add_job(restart_space, 'interval', seconds=3600)
212
+ scheduler.start()
213
 
214
  demo.launch()