patrickvonplaten commited on
Commit
e0191f6
β€’
1 Parent(s): 3acffd5
Files changed (1) hide show
  1. @ +0 -98
@ DELETED
@@ -1,98 +0,0 @@
1
- from datasets import load_dataset
2
- from collections import Counter, defaultdict
3
- from random import sample, shuffle
4
- import datasets
5
- from pandas import DataFrame
6
- from huggingface_hub import list_datasets
7
- import os
8
- import gradio as gr
9
-
10
- import secrets
11
-
12
- from traitlets import default
13
-
14
- parti_prompt_results = []
15
- ORG = "diffusers-parti-prompts"
16
- SUBMISSIONS = {
17
- "sd-v1-5": None,
18
- "sd-v2-1": None,
19
- "if-v1-0": None,
20
- "karlo": None,
21
- }
22
- LINKS = {
23
- "sd-v1-5": "https://huggingface.co/runwayml/stable-diffusion-v1-5",
24
- "sd-v2-1": "https://huggingface.co/stabilityai/stable-diffusion-2-1",
25
- "if-v1-0": "https://huggingface.co/DeepFloyd/IF-I-XL-v1.0",
26
- "karlo": "https://huggingface.co/kakaobrain/karlo-v1-alpha",
27
- }
28
- MODEL_KEYS = "-".join(SUBMISSIONS.keys())
29
- SUBMISSION_ORG = f"results-{MODEL_KEYS}"
30
-
31
- submission_names = list(SUBMISSIONS.keys())
32
- parti_prompt_categories = load_dataset(os.path.join(ORG, "sd-v1-5"))["train"]["Category"]
33
- parti_prompt_challenge = load_dataset(os.path.join(ORG, "sd-v1-5"))["train"]["Challenge"]
34
-
35
-
36
- def load_submissions():
37
- all_datasets = list_datasets(author=SUBMISSION_ORG)
38
- relevant_ids = [d.id for d in all_datasets]
39
-
40
- ids = defaultdict(list)
41
- challenges = defaultdict(list)
42
- categories = defaultdict(list)
43
-
44
- for _id in relevant_ids[:2]:
45
- ds = load_dataset(_id)["train"]
46
- for result, image_id in zip(ds["result"], ds["id"]):
47
- ids[result].append(image_id)
48
- challenges[parti_prompt_challenge[image_id]].append(result)
49
- categories[parti_prompt_categories[image_id]].append(result)
50
-
51
- main_dict = {k: len(v) for k, v in ids.item()}
52
- challenges = {k: Counter(v) for k, v in challenges.item()}
53
- categories = {k: Counter(v) for k, v in categories.item()}
54
-
55
- return main_dict, challenges, categories
56
-
57
- def get_dataframe_all():
58
- main, challanges, categories= load_submissions()
59
- import ipdb; ipdb.set_trace()
60
-
61
- TITLE = "# Community Parti Prompts - Who is your open-source genAI model?"
62
- DESCRIPTION = """
63
- *This is an interactive game in which you click through pre-generated images from SD-v1-5, SD-v2.1, Karlo, and IF
64
- using [Parti Prompts](https://huggingface.co/datasets/nateraw/parti-prompts) prompts.* \n
65
- *You choices will go into the public community [genAI leaderboard](TODO).*
66
- """
67
- EXPLANATION = """\n\n
68
- ## How it works πŸ“– \n\n
69
-
70
- 1. Click on 'Start'
71
- 2. A prompt and 4 different images are displayed
72
- 3. Select your favorite image
73
- 4. After 10 rounds your favorite diffusion model is displayed
74
- """
75
-
76
- GALLERY_COLUMN_NUM = len(SUBMISSIONS)
77
-
78
- with gr.Blocks() as demo:
79
- with gr.Column(visible=True) as intro_view:
80
- gr.Markdown(TITLE)
81
- gr.Markdown(DESCRIPTION)
82
- gr.Markdown(EXPLANATION)
83
-
84
- headers = list(SUBMISSIONS.keys())
85
- datatype = "str"
86
-
87
- dataframes = get_dataframe_all()
88
- import ipdb; ipdb.set_trace()
89
-
90
- main_dataframe = gr.Dataframe(
91
- headers=headers,
92
- datatype=datatype,
93
- row_count=1,
94
- col_count=(len(SUBMISSIONS)),
95
- interactive=False,
96
- )
97
-
98
- demo.launch()