Spaces:
Running
Running
change the title name in main.py
Browse files
main.py
CHANGED
@@ -1,89 +1,89 @@
|
|
1 |
-
import streamlit as st
|
2 |
-
import pandas as pd
|
3 |
-
import json
|
4 |
-
|
5 |
-
# 读取 JSON 数据
|
6 |
-
with open('GenAI-Bench_tags.json', 'r') as file:
|
7 |
-
data = json.load(file)
|
8 |
-
|
9 |
-
# Streamlit 页面标题
|
10 |
-
|
11 |
-
st.set_page_config(page_title="GenAI-Bench Dataset Viewer", page_icon=None, layout="wide", initial_sidebar_state="auto",
|
12 |
-
menu_items=None)
|
13 |
-
st.title('GenAI
|
14 |
-
# 多选框
|
15 |
-
basic_options = []
|
16 |
-
advanced_options = []
|
17 |
-
|
18 |
-
for i in data:
|
19 |
-
data[i]['basic'].sort()
|
20 |
-
data[i]['advanced'].sort()
|
21 |
-
|
22 |
-
for basic in data[i]['basic']:
|
23 |
-
if basic not in basic_options:
|
24 |
-
basic_options.append(basic)
|
25 |
-
for adv in data[i]['advanced']:
|
26 |
-
if adv not in advanced_options:
|
27 |
-
advanced_options.append(adv)
|
28 |
-
data[i]['id'] = i
|
29 |
-
# modles = ["DALLE_3","DeepFloyd_I_XL_v1","Midjourney_6","SDXL_2_1","SDXL_Base","SDXL_Turbo"]
|
30 |
-
data[i]['DALLE_3'] = f"app/static/DALLE_3/{i}.jpeg"
|
31 |
-
data[i]['DeepFloyd_I_XL_v1'] = f"app/static/DeepFloyd_I_XL_v1/{i}.jpeg"
|
32 |
-
data[i]['Midjourney_6'] = f"app/static/Midjourney_6/{i}.jpeg"
|
33 |
-
data[i]['SDXL_2_1'] = f"app/static/SDXL_2_1/{i}.jpeg"
|
34 |
-
data[i]['SDXL_Base'] = f"app/static/SDXL_Base/{i}.jpeg"
|
35 |
-
data[i]['SDXL_Turbo'] = f"app/static/SDXL_Turbo/{i}.jpeg"
|
36 |
-
|
37 |
-
data[i]['DALLE_3_Human'] = -1
|
38 |
-
data[i]['DeepFloyd_I_XL_v1_Human'] = -1
|
39 |
-
data[i]['Midjourney_6_Human'] = -1
|
40 |
-
data[i]['SDXL_2_1_Human'] = -1
|
41 |
-
data[i]['SDXL_Base_Human'] = -1
|
42 |
-
data[i]['SDXL_Turbo_Human'] = -1
|
43 |
-
|
44 |
-
selected_basic = st.multiselect('Select Basic Skills:', basic_options)
|
45 |
-
selected_advanced = st.multiselect('Select Advanced Skills:', advanced_options)
|
46 |
-
|
47 |
-
# 筛选数据
|
48 |
-
filtered_data = [
|
49 |
-
data[item] for item in data
|
50 |
-
if all(elem in data[item]['basic'] for elem in selected_basic) and
|
51 |
-
all(advanced in data[item]['advanced'] for advanced in selected_advanced)
|
52 |
-
]
|
53 |
-
|
54 |
-
# 显示筛选后的数据
|
55 |
-
if filtered_data:
|
56 |
-
df = pd.DataFrame(filtered_data)
|
57 |
-
df = df.reindex(columns=["id", "prompt", "basic", "advanced", "DALLE_3", "DALLE_3_Human", "DeepFloyd_I_XL_v1",
|
58 |
-
"DeepFloyd_I_XL_v1_Human", "Midjourney_6", "Midjourney_6_Human", "SDXL_2_1",
|
59 |
-
"SDXL_2_1_Human", "SDXL_Base", "SDXL_Base_Human", "SDXL_Turbo", "SDXL_Turbo_Human"])
|
60 |
-
# df['pic'] = df['pic'].apply(lambda x: f'< img src="{x}" width="60">')
|
61 |
-
# st.write(df.to_html(escape=False), unsafe_allow_html=True)
|
62 |
-
st.dataframe(data=df, width = 4096, height = 800,
|
63 |
-
column_config={
|
64 |
-
"name": "Data Explorer",
|
65 |
-
"id": st.column_config.NumberColumn("ID", format="%d", width="small"),
|
66 |
-
'basic': st.column_config.ListColumn(label="Basic Skills", width="large", help=None),
|
67 |
-
'advanced': st.column_config.ListColumn(label="Advanced Skills", width="large", help=None),
|
68 |
-
'prompt': st.column_config.TextColumn(label="Prompt", width="large", help=None, disabled=None,
|
69 |
-
required=None,
|
70 |
-
default=None, max_chars=None, validate=None),
|
71 |
-
"DALLE_3": st.column_config.ImageColumn(label="DALLE_3", width="small", help=None),
|
72 |
-
"DAllE_3_Human": st.column_config.NumberColumn("Rating Human", format="%d", width="small", help="Rating Human for DALLE_3"),
|
73 |
-
"DeepFloyd_I_XL_v1": st.column_config.ImageColumn(label="DeepFloyd", width="small",
|
74 |
-
help="DeepFloyd_I_XL_v1"),
|
75 |
-
"DeepFloyd_I_XL_v1_Human": st.column_config.NumberColumn("Rating Human", format="%d",
|
76 |
-
width="small", help="Rating Human for DeepFloyd"),
|
77 |
-
"Midjourney_6": st.column_config.ImageColumn(label="Midjourney", width="small", help="Midjourney_6"),
|
78 |
-
"Midjourney_6_Human": st.column_config.NumberColumn("Rating Human", format="%d",
|
79 |
-
width="small", help="Rating Human for Midjourney_6"),
|
80 |
-
"SDXL_2_1": st.column_config.ImageColumn(label="SDXL_2_1", width="small", help=None),
|
81 |
-
"SDXL_2_1_Human": st.column_config.NumberColumn("Rating Human", format="%d", width="small", help="Rating Human for SDXL_2_1"),
|
82 |
-
"SDXL_Base": st.column_config.ImageColumn(label="SDXL_Base", width="small", help=None),
|
83 |
-
"SDXL_Base_Human": st.column_config.NumberColumn("Rating Human", format="%d", width="small", help="Rating Human for SDXL_Base"),
|
84 |
-
"SDXL_Turbo": st.column_config.ImageColumn(label="SDXL_Turbo", width="small", help=None),
|
85 |
-
"SDXL_Turbo_Human": st.column_config.NumberColumn("Rating Human", format="%d", width="small", help="Rating Human for SDXL_Turbo"),
|
86 |
-
},
|
87 |
-
hide_index=True, selection_mode="single-row")
|
88 |
-
else:
|
89 |
-
st.write("No data matches the selected filters.")
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
import json
|
4 |
+
|
5 |
+
# 读取 JSON 数据
|
6 |
+
with open('GenAI-Bench_tags.json', 'r') as file:
|
7 |
+
data = json.load(file)
|
8 |
+
|
9 |
+
# Streamlit 页面标题
|
10 |
+
|
11 |
+
st.set_page_config(page_title="GenAI-Bench Dataset Viewer", page_icon=None, layout="wide", initial_sidebar_state="auto",
|
12 |
+
menu_items=None)
|
13 |
+
st.title('GenAI-Bench Dataset Viewer')
|
14 |
+
# 多选框
|
15 |
+
basic_options = []
|
16 |
+
advanced_options = []
|
17 |
+
|
18 |
+
for i in data:
|
19 |
+
data[i]['basic'].sort()
|
20 |
+
data[i]['advanced'].sort()
|
21 |
+
|
22 |
+
for basic in data[i]['basic']:
|
23 |
+
if basic not in basic_options:
|
24 |
+
basic_options.append(basic)
|
25 |
+
for adv in data[i]['advanced']:
|
26 |
+
if adv not in advanced_options:
|
27 |
+
advanced_options.append(adv)
|
28 |
+
data[i]['id'] = i
|
29 |
+
# modles = ["DALLE_3","DeepFloyd_I_XL_v1","Midjourney_6","SDXL_2_1","SDXL_Base","SDXL_Turbo"]
|
30 |
+
data[i]['DALLE_3'] = f"app/static/DALLE_3/{i}.jpeg"
|
31 |
+
data[i]['DeepFloyd_I_XL_v1'] = f"app/static/DeepFloyd_I_XL_v1/{i}.jpeg"
|
32 |
+
data[i]['Midjourney_6'] = f"app/static/Midjourney_6/{i}.jpeg"
|
33 |
+
data[i]['SDXL_2_1'] = f"app/static/SDXL_2_1/{i}.jpeg"
|
34 |
+
data[i]['SDXL_Base'] = f"app/static/SDXL_Base/{i}.jpeg"
|
35 |
+
data[i]['SDXL_Turbo'] = f"app/static/SDXL_Turbo/{i}.jpeg"
|
36 |
+
|
37 |
+
data[i]['DALLE_3_Human'] = -1
|
38 |
+
data[i]['DeepFloyd_I_XL_v1_Human'] = -1
|
39 |
+
data[i]['Midjourney_6_Human'] = -1
|
40 |
+
data[i]['SDXL_2_1_Human'] = -1
|
41 |
+
data[i]['SDXL_Base_Human'] = -1
|
42 |
+
data[i]['SDXL_Turbo_Human'] = -1
|
43 |
+
|
44 |
+
selected_basic = st.multiselect('Select Basic Skills:', basic_options)
|
45 |
+
selected_advanced = st.multiselect('Select Advanced Skills:', advanced_options)
|
46 |
+
|
47 |
+
# 筛选数据
|
48 |
+
filtered_data = [
|
49 |
+
data[item] for item in data
|
50 |
+
if all(elem in data[item]['basic'] for elem in selected_basic) and
|
51 |
+
all(advanced in data[item]['advanced'] for advanced in selected_advanced)
|
52 |
+
]
|
53 |
+
|
54 |
+
# 显示筛选后的数据
|
55 |
+
if filtered_data:
|
56 |
+
df = pd.DataFrame(filtered_data)
|
57 |
+
df = df.reindex(columns=["id", "prompt", "basic", "advanced", "DALLE_3", "DALLE_3_Human", "DeepFloyd_I_XL_v1",
|
58 |
+
"DeepFloyd_I_XL_v1_Human", "Midjourney_6", "Midjourney_6_Human", "SDXL_2_1",
|
59 |
+
"SDXL_2_1_Human", "SDXL_Base", "SDXL_Base_Human", "SDXL_Turbo", "SDXL_Turbo_Human"])
|
60 |
+
# df['pic'] = df['pic'].apply(lambda x: f'< img src="{x}" width="60">')
|
61 |
+
# st.write(df.to_html(escape=False), unsafe_allow_html=True)
|
62 |
+
st.dataframe(data=df, width = 4096, height = 800,
|
63 |
+
column_config={
|
64 |
+
"name": "Data Explorer",
|
65 |
+
"id": st.column_config.NumberColumn("ID", format="%d", width="small"),
|
66 |
+
'basic': st.column_config.ListColumn(label="Basic Skills", width="large", help=None),
|
67 |
+
'advanced': st.column_config.ListColumn(label="Advanced Skills", width="large", help=None),
|
68 |
+
'prompt': st.column_config.TextColumn(label="Prompt", width="large", help=None, disabled=None,
|
69 |
+
required=None,
|
70 |
+
default=None, max_chars=None, validate=None),
|
71 |
+
"DALLE_3": st.column_config.ImageColumn(label="DALLE_3", width="small", help=None),
|
72 |
+
"DAllE_3_Human": st.column_config.NumberColumn("Rating Human", format="%d", width="small", help="Rating Human for DALLE_3"),
|
73 |
+
"DeepFloyd_I_XL_v1": st.column_config.ImageColumn(label="DeepFloyd", width="small",
|
74 |
+
help="DeepFloyd_I_XL_v1"),
|
75 |
+
"DeepFloyd_I_XL_v1_Human": st.column_config.NumberColumn("Rating Human", format="%d",
|
76 |
+
width="small", help="Rating Human for DeepFloyd"),
|
77 |
+
"Midjourney_6": st.column_config.ImageColumn(label="Midjourney", width="small", help="Midjourney_6"),
|
78 |
+
"Midjourney_6_Human": st.column_config.NumberColumn("Rating Human", format="%d",
|
79 |
+
width="small", help="Rating Human for Midjourney_6"),
|
80 |
+
"SDXL_2_1": st.column_config.ImageColumn(label="SDXL_2_1", width="small", help=None),
|
81 |
+
"SDXL_2_1_Human": st.column_config.NumberColumn("Rating Human", format="%d", width="small", help="Rating Human for SDXL_2_1"),
|
82 |
+
"SDXL_Base": st.column_config.ImageColumn(label="SDXL_Base", width="small", help=None),
|
83 |
+
"SDXL_Base_Human": st.column_config.NumberColumn("Rating Human", format="%d", width="small", help="Rating Human for SDXL_Base"),
|
84 |
+
"SDXL_Turbo": st.column_config.ImageColumn(label="SDXL_Turbo", width="small", help=None),
|
85 |
+
"SDXL_Turbo_Human": st.column_config.NumberColumn("Rating Human", format="%d", width="small", help="Rating Human for SDXL_Turbo"),
|
86 |
+
},
|
87 |
+
hide_index=True, selection_mode="single-row")
|
88 |
+
else:
|
89 |
+
st.write("No data matches the selected filters.")
|