Spaces:
Sleeping
Sleeping
summary page new option
Browse files- Home.py +14 -8
- pages/Summary.py +76 -59
Home.py
CHANGED
@@ -38,22 +38,28 @@ def logout():
|
|
38 |
st.session_state.pop('score_weights', None)
|
39 |
|
40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
if __name__ == '__main__':
|
42 |
# print(st.source_util.get_pages('Home.py'))
|
43 |
-
|
44 |
st.set_page_config(page_title="Login", page_icon="π ", layout="wide")
|
|
|
45 |
st.write('A Research by [MAPS Lab](https://whongyi.github.io/MAPS-research), [NYU Shanghai](https://shanghai.nyu.edu)')
|
46 |
st.title("π Welcome to GEMRec Gallery Webapp!")
|
47 |
st.info("Getting obsessed with tons of different text-to-image generation models available online? \n \
|
48 |
Want to find the most suitable one for your taste? \n \
|
49 |
**GEMRec** is here to help you!"
|
50 |
-
)
|
51 |
-
st.write(
|
52 |
-
"This is an web application to collect personal preference to images synthesised by generative models fine-tuned on stable diffusion. \
|
53 |
-
**You might consider it as a tool for quickly digging out the most suitable text-to-image generation model for you from [civitai](https://civitai.com/).**"
|
54 |
-
)
|
55 |
-
st.write(
|
56 |
-
"After you picking images from gallery page, and ranking them in the ranking page, you will be able to see a dashboard showing your preferred models in the summary page, **with download links of the models ready to use in [Automatic1111 webui](https://github.com/AUTOMATIC1111/stable-diffusion-webui)!**"
|
57 |
)
|
58 |
|
59 |
if 'user_id' not in st.session_state:
|
|
|
38 |
st.session_state.pop('score_weights', None)
|
39 |
|
40 |
|
41 |
+
def info():
|
42 |
+
with st.sidebar:
|
43 |
+
st.write('## About')
|
44 |
+
|
45 |
+
st.write(
|
46 |
+
"This is an web application to collect personal preference to images synthesised by generative models fine-tuned on stable diffusion. \
|
47 |
+
**You might consider it as a tool for quickly digging out the most suitable text-to-image generation model for you from [civitai](https://civitai.com/).**"
|
48 |
+
)
|
49 |
+
st.write(
|
50 |
+
"After you picking images from gallery page, and ranking them in the ranking page, you will be able to see a dashboard showing your preferred models in the summary page, **with download links of the models ready to use in [Automatic1111 webui](https://github.com/AUTOMATIC1111/stable-diffusion-webui)!**"
|
51 |
+
)
|
52 |
+
|
53 |
+
|
54 |
if __name__ == '__main__':
|
55 |
# print(st.source_util.get_pages('Home.py'))
|
|
|
56 |
st.set_page_config(page_title="Login", page_icon="π ", layout="wide")
|
57 |
+
info()
|
58 |
st.write('A Research by [MAPS Lab](https://whongyi.github.io/MAPS-research), [NYU Shanghai](https://shanghai.nyu.edu)')
|
59 |
st.title("π Welcome to GEMRec Gallery Webapp!")
|
60 |
st.info("Getting obsessed with tons of different text-to-image generation models available online? \n \
|
61 |
Want to find the most suitable one for your taste? \n \
|
62 |
**GEMRec** is here to help you!"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
)
|
64 |
|
65 |
if 'user_id' not in st.session_state:
|
pages/Summary.py
CHANGED
@@ -43,72 +43,89 @@ class DashboardApp:
|
|
43 |
|
44 |
tab1, tab2 = st.tabs(['Top Picks', 'Detailed Info'])
|
45 |
|
46 |
-
|
47 |
with tab1:
|
48 |
-
#
|
49 |
-
|
50 |
-
n = 3
|
51 |
-
metric_cols = st.columns(n)
|
52 |
-
image_display = st.empty()
|
53 |
-
|
54 |
-
for i in range(n):
|
55 |
-
with metric_cols[i]:
|
56 |
-
modelVersion_id = modelVersion_standings[i][0]
|
57 |
-
winning_times = modelVersion_standings[i][1]
|
58 |
-
|
59 |
-
model_id, model_name, modelVersion_name, url = self.roster[self.roster['modelVersion_id'] == modelVersion_id][['model_id', 'model_name', 'modelVersion_name', 'modelVersion_url']].values[0]
|
60 |
-
|
61 |
-
metric_card = stylable_container(
|
62 |
-
key="container_with_border",
|
63 |
-
css_styles="""
|
64 |
-
{
|
65 |
-
border: 1.5px solid rgba(49, 51, 63, 0.2);
|
66 |
-
border-left: 0.5rem solid gold;
|
67 |
-
border-radius: 5px;
|
68 |
-
padding: calc(1em + 5px);
|
69 |
-
gap: 0.5em;
|
70 |
-
box-shadow: 0 0 2rem rgba(0, 0, 0, 0.08);
|
71 |
-
overflow-x: scroll;
|
72 |
-
}
|
73 |
-
""",
|
74 |
-
)
|
75 |
-
|
76 |
-
with metric_card:
|
77 |
-
icon = 'π₯'if i == 0 else 'π₯' if i == 1 else 'π₯'
|
78 |
-
# st.write(model_id)
|
79 |
-
st.write(f'### {icon} {model_name}, [{modelVersion_name}](https://civitai.com/models/{model_id}?modelVersionId={modelVersion_id})')
|
80 |
-
st.write(f'Ranking Score: {winning_times}')
|
81 |
-
|
82 |
-
show_image = st.button('Show Image', key=modelVersion_id, use_container_width=True)
|
83 |
-
if show_image:
|
84 |
-
|
85 |
-
images = self.promptBook[self.promptBook['modelVersion_id'] == modelVersion_id]['image_id'].values
|
86 |
-
with image_display.container():
|
87 |
-
st.write('---')
|
88 |
-
st.write(f'### Images generated with {icon} {model_name}, {modelVersion_name}')
|
89 |
-
col_num = 4
|
90 |
-
image_cols = st.columns(col_num)
|
91 |
-
for i in range(len(images)):
|
92 |
-
with image_cols[i % col_num]:
|
93 |
-
image = f"https://modelcofferbucket.s3-accelerate.amazonaws.com/{images[i]}.png"
|
94 |
-
st.image(image, use_column_width=True)
|
95 |
-
|
96 |
-
|
97 |
-
# # st.write('---')
|
98 |
-
# expander = st.expander(f'# {icon} {model_name}, [{modelVersion_name}](https://civitai.com/models/{modelVersion_id})')
|
99 |
-
# with expander:
|
100 |
-
# images = self.promptBook[self.promptBook['modelVersion_id'] == modelVersion_id]['image_id'].values
|
101 |
-
# st.write(images)
|
102 |
-
|
103 |
-
st.chat_input('Please leave your comments here.', key='comment')
|
104 |
|
105 |
with tab2:
|
106 |
st.write('## Detailed information of all selected models')
|
107 |
detailed_info = pd.merge(pd.DataFrame(modelVersion_standings, columns=['modelVersion_id', 'ranking_score']), self.roster, on='modelVersion_id')
|
108 |
st.data_editor(detailed_info, hide_index=True, disabled=True)
|
109 |
|
110 |
-
|
111 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
|
113 |
def score_calculator(self, results, db_table):
|
114 |
# sort results by battle time
|
|
|
43 |
|
44 |
tab1, tab2 = st.tabs(['Top Picks', 'Detailed Info'])
|
45 |
|
|
|
46 |
with tab1:
|
47 |
+
# self.podium(modelVersion_standings)
|
48 |
+
self.podium_expander(modelVersion_standings)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
|
50 |
with tab2:
|
51 |
st.write('## Detailed information of all selected models')
|
52 |
detailed_info = pd.merge(pd.DataFrame(modelVersion_standings, columns=['modelVersion_id', 'ranking_score']), self.roster, on='modelVersion_id')
|
53 |
st.data_editor(detailed_info, hide_index=True, disabled=True)
|
54 |
|
55 |
+
def podium(self, modelVersion_standings, n=3):
|
56 |
+
st.write('## Top picks')
|
57 |
+
metric_cols = st.columns(n)
|
58 |
+
image_display = st.empty()
|
59 |
+
|
60 |
+
for i in range(n):
|
61 |
+
with metric_cols[i]:
|
62 |
+
modelVersion_id = modelVersion_standings[i][0]
|
63 |
+
winning_times = modelVersion_standings[i][1]
|
64 |
+
|
65 |
+
model_id, model_name, modelVersion_name, url = self.roster[self.roster['modelVersion_id'] == modelVersion_id][['model_id', 'model_name', 'modelVersion_name', 'modelVersion_url']].values[0]
|
66 |
+
|
67 |
+
metric_card = stylable_container(
|
68 |
+
key="container_with_border",
|
69 |
+
css_styles="""
|
70 |
+
{
|
71 |
+
border: 1.5px solid rgba(49, 51, 63, 0.2);
|
72 |
+
border-left: 0.5rem solid gold;
|
73 |
+
border-radius: 5px;
|
74 |
+
padding: calc(1em + 5px);
|
75 |
+
gap: 0.5em;
|
76 |
+
box-shadow: 0 0 2rem rgba(0, 0, 0, 0.08);
|
77 |
+
overflow-x: scroll;
|
78 |
+
}
|
79 |
+
""",
|
80 |
+
)
|
81 |
+
|
82 |
+
with metric_card:
|
83 |
+
icon = 'π₯'if i == 0 else 'π₯' if i == 1 else 'π₯'
|
84 |
+
# st.write(model_id)
|
85 |
+
st.write(f'### {icon} {model_name}, [{modelVersion_name}](https://civitai.com/models/{model_id}?modelVersionId={modelVersion_id})')
|
86 |
+
st.write(f'Ranking Score: {winning_times}')
|
87 |
+
|
88 |
+
show_image = st.button('Show Image', key=modelVersion_id, use_container_width=True)
|
89 |
+
if show_image:
|
90 |
+
|
91 |
+
images = self.promptBook[self.promptBook['modelVersion_id'] == modelVersion_id]['image_id'].values
|
92 |
+
with image_display.container():
|
93 |
+
st.write('---')
|
94 |
+
st.write(f'### Images generated with {icon} {model_name}, {modelVersion_name}')
|
95 |
+
col_num = 4
|
96 |
+
image_cols = st.columns(col_num)
|
97 |
+
for i in range(len(images)):
|
98 |
+
with image_cols[i % col_num]:
|
99 |
+
image = f"https://modelcofferbucket.s3-accelerate.amazonaws.com/{images[i]}.png"
|
100 |
+
st.image(image, use_column_width=True)
|
101 |
+
|
102 |
+
|
103 |
+
# # st.write('---')
|
104 |
+
# expander = st.expander(f'# {icon} {model_name}, [{modelVersion_name}](https://civitai.com/models/{modelVersion_id})')
|
105 |
+
# with expander:
|
106 |
+
# images = self.promptBook[self.promptBook['modelVersion_id'] == modelVersion_id]['image_id'].values
|
107 |
+
# st.write(images)
|
108 |
+
|
109 |
+
def podium_expander(self, modelVersion_standings, n=3):
|
110 |
+
st.write('## Top picks')
|
111 |
+
# metric_cols = st.columns(n)
|
112 |
+
for i in range(n):
|
113 |
+
# with metric_cols[i]:
|
114 |
+
modelVersion_id = modelVersion_standings[i][0]
|
115 |
+
winning_times = modelVersion_standings[i][1]
|
116 |
+
|
117 |
+
model_id, model_name, modelVersion_name, url = self.roster[self.roster['modelVersion_id'] == modelVersion_id][['model_id', 'model_name', 'modelVersion_name', 'modelVersion_url']].values[0]
|
118 |
+
|
119 |
+
icon = 'π₯'if i == 0 else 'π₯' if i == 1 else 'π₯'
|
120 |
+
with st.expander(f'**{icon} {model_name}, [{modelVersion_name}](https://civitai.com/models/{model_id}?modelVersionId={modelVersion_id})**, Ranking Score: {winning_times}'):
|
121 |
+
images = self.promptBook[self.promptBook['modelVersion_id'] == modelVersion_id]['image_id'].values
|
122 |
+
st.write(f'### Images generated with {icon} {model_name}, {modelVersion_name}')
|
123 |
+
col_num = 4
|
124 |
+
image_cols = st.columns(col_num)
|
125 |
+
for i in range(len(images)):
|
126 |
+
with image_cols[i % col_num]:
|
127 |
+
image = f"https://modelcofferbucket.s3-accelerate.amazonaws.com/{images[i]}.png"
|
128 |
+
st.image(image, use_column_width=True)
|
129 |
|
130 |
def score_calculator(self, results, db_table):
|
131 |
# sort results by battle time
|