Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
patrickvonplaten
commited on
Commit
·
c49a274
1
Parent(s):
6d4e0ea
correct
Browse files- __pycache__/app.cpython-310.pyc +0 -0
- app.py +16 -5
__pycache__/app.cpython-310.pyc
CHANGED
Binary files a/__pycache__/app.cpython-310.pyc and b/__pycache__/app.cpython-310.pyc differ
|
|
app.py
CHANGED
@@ -35,19 +35,26 @@ def load_submissions():
|
|
35 |
challenges = defaultdict(list)
|
36 |
categories = defaultdict(list)
|
37 |
|
|
|
|
|
38 |
for _id in relevant_ids:
|
39 |
ds = load_dataset(_id)["train"]
|
40 |
for result, image_id in zip(ds["result"], ds["id"]):
|
|
|
|
|
|
|
|
|
41 |
ids[result].append(image_id)
|
42 |
challenges[parti_prompt_challenge[image_id]].append(result)
|
43 |
categories[parti_prompt_categories[image_id]].append(result)
|
|
|
44 |
|
45 |
all_values = sum(len(v) for v in ids.values())
|
46 |
main_dict = {k: '{:.2%}'.format(len(v)/all_values) for k, v in ids.items()}
|
47 |
challenges = {k: Counter(v) for k, v in challenges.items()}
|
48 |
categories = {k: Counter(v) for k, v in categories.items()}
|
49 |
|
50 |
-
return main_dict, challenges, categories
|
51 |
|
52 |
def sort_by_highest_percentage(df):
|
53 |
# Convert percentage values to numeric format
|
@@ -56,7 +63,7 @@ def sort_by_highest_percentage(df):
|
|
56 |
return df
|
57 |
|
58 |
def get_dataframe_all():
|
59 |
-
main, challenges, categories = load_submissions()
|
60 |
main_frame = pd.DataFrame([main])
|
61 |
|
62 |
challenges_frame = pd.DataFrame.from_dict(challenges).fillna(0).T
|
@@ -75,7 +82,7 @@ def get_dataframe_all():
|
|
75 |
categories_frame = categories_frame.reset_index().rename(columns={'index': 'Category'})
|
76 |
challenges_frame = challenges_frame.reset_index().rename(columns={'index': 'Challenge'})
|
77 |
|
78 |
-
return main_frame, challenges_frame, categories_frame
|
79 |
|
80 |
TITLE = "# Open Parti Prompts Leaderboard"
|
81 |
DESCRIPTION = """
|
@@ -113,7 +120,7 @@ with gr.Blocks() as demo:
|
|
113 |
headers = list(SUBMISSIONS.keys())
|
114 |
datatype = "str"
|
115 |
|
116 |
-
main_df, challenge_df, category_df = get_dataframe_all()
|
117 |
|
118 |
with gr.Column():
|
119 |
gr.Markdown("# Open Parti Prompts")
|
@@ -148,8 +155,12 @@ with gr.Blocks() as demo:
|
|
148 |
interactive=False,
|
149 |
)
|
150 |
|
|
|
|
|
|
|
|
|
151 |
with gr.Row():
|
152 |
refresh_button = gr.Button("Refresh")
|
153 |
-
refresh_button.click(refresh, inputs=[], outputs=[main_dataframe, cat_dataframe, chal_dataframe])
|
154 |
|
155 |
demo.launch()
|
|
|
35 |
challenges = defaultdict(list)
|
36 |
categories = defaultdict(list)
|
37 |
|
38 |
+
total_submissions = 0
|
39 |
+
|
40 |
for _id in relevant_ids:
|
41 |
ds = load_dataset(_id)["train"]
|
42 |
for result, image_id in zip(ds["result"], ds["id"]):
|
43 |
+
if result not in submission_names:
|
44 |
+
# Make sure that incorrect model names are not added
|
45 |
+
continue
|
46 |
+
|
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 |
+
total_submissions += 1
|
51 |
|
52 |
all_values = sum(len(v) for v in ids.values())
|
53 |
main_dict = {k: '{:.2%}'.format(len(v)/all_values) for k, v in ids.items()}
|
54 |
challenges = {k: Counter(v) for k, v in challenges.items()}
|
55 |
categories = {k: Counter(v) for k, v in categories.items()}
|
56 |
|
57 |
+
return total_submissions, main_dict, challenges, categories
|
58 |
|
59 |
def sort_by_highest_percentage(df):
|
60 |
# Convert percentage values to numeric format
|
|
|
63 |
return df
|
64 |
|
65 |
def get_dataframe_all():
|
66 |
+
total_submissions, main, challenges, categories = load_submissions()
|
67 |
main_frame = pd.DataFrame([main])
|
68 |
|
69 |
challenges_frame = pd.DataFrame.from_dict(challenges).fillna(0).T
|
|
|
82 |
categories_frame = categories_frame.reset_index().rename(columns={'index': 'Category'})
|
83 |
challenges_frame = challenges_frame.reset_index().rename(columns={'index': 'Challenge'})
|
84 |
|
85 |
+
return total_submissions, main_frame, challenges_frame, categories_frame
|
86 |
|
87 |
TITLE = "# Open Parti Prompts Leaderboard"
|
88 |
DESCRIPTION = """
|
|
|
120 |
headers = list(SUBMISSIONS.keys())
|
121 |
datatype = "str"
|
122 |
|
123 |
+
total_submissions, main_df, challenge_df, category_df = get_dataframe_all()
|
124 |
|
125 |
with gr.Column():
|
126 |
gr.Markdown("# Open Parti Prompts")
|
|
|
155 |
interactive=False,
|
156 |
)
|
157 |
|
158 |
+
with gr.Column():
|
159 |
+
gr.Markdown("## # Submissions")
|
160 |
+
num_submissions = gr.Number(value=total_submissions, interactive=False)
|
161 |
+
|
162 |
with gr.Row():
|
163 |
refresh_button = gr.Button("Refresh")
|
164 |
+
refresh_button.click(refresh, inputs=[], outputs=[num_submissions, main_dataframe, cat_dataframe, chal_dataframe])
|
165 |
|
166 |
demo.launch()
|