Ricercar commited on
Commit
2cd207c
1 Parent(s): 63467de

upload files

Browse files
.gitignore ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ .DS_Store?
2
+ ehthumbs.db
3
+ Icon?
4
+ Thumbs.db
5
+ *.DS_Store
6
+ secret.sh
app.py ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import numpy as np
3
+ import random
4
+ import pandas as pd
5
+ import glob
6
+ import csv
7
+ from PIL import Image
8
+ from datasets import load_dataset, Dataset, load_from_disk
9
+ from huggingface_hub import login
10
+ import os
11
+
12
+
13
+ class GalleryApp:
14
+ def __init__(self, promptBook):
15
+ self.promptBook = promptBook
16
+ st.set_page_config(layout="wide")
17
+
18
+
19
+ def gallery(self, items, col_num, info):
20
+ cols = st.columns(col_num)
21
+ # # sort items by brisque score
22
+ # items = items.sort_values(by=['brisque'], ascending=True).reset_index(drop=True)
23
+ for idx in range(len(items)):
24
+ with cols[idx % col_num]:
25
+ image = st.session_state.images[items.iloc[idx]['row_idx'].item()]['image']
26
+ st.image(image,
27
+ use_column_width=True,
28
+ )
29
+ for key in info:
30
+ st.write(f"**{key}**: {items.iloc[idx][key]}")
31
+
32
+ def app(self):
33
+ st.title('Model Coffer Gallery')
34
+ st.write('This is a gallery of images generated by the models in the Model Coffer')
35
+
36
+ metadata, images = st.columns([1, 3])
37
+ # with images:
38
+ # prompt_tags = self.promptBook['tag'].unique()
39
+ # # sort tags by alphabetical order
40
+ # prompt_tags = np.sort(prompt_tags)
41
+ #
42
+ # selecters = st.columns(3)
43
+ # with selecters[0]:
44
+ # tag = st.selectbox('Select a tag', prompt_tags)
45
+
46
+ with metadata:
47
+ prompt_tags = self.promptBook['tag'].unique()
48
+ # sort tags by alphabetical order
49
+ prompt_tags = np.sort(prompt_tags)
50
+
51
+ tag = st.selectbox('Select a tag', prompt_tags)
52
+
53
+ items = self.promptBook[self.promptBook['tag'] == tag].reset_index(drop=True)
54
+
55
+ prompts = [', '.join(x.split(', ')[4:]) for x in items['prompt'].unique()]
56
+ prompt = st.selectbox('Select prompt', prompts)
57
+
58
+ idx = prompts.index(prompt)
59
+ prompt_full = ', '.join(items['prompt'].unique()[idx].split(', ')[:4]) + ', ' + prompt
60
+
61
+ prompt_id = items[items['prompt'] == prompt_full]['prompt_id'].unique()[0]
62
+ items = items[items['prompt_id'] == prompt_id].reset_index(drop=True)
63
+
64
+ st.write('**Prompt ID**')
65
+ st.caption(f"{prompt_id}")
66
+ st.write('**Prompt**')
67
+ st.caption(f"{items['prompt'][0]}")
68
+ st.write('**Negative Prompt**')
69
+ st.caption(f"{items['negativePrompt'][0]}")
70
+ st.write('**Sampler**')
71
+ st.caption(f"{items['sampler'][0]}")
72
+ st.write('**cfgScale**')
73
+ st.caption(f"{items['cfgScale'][0]}")
74
+ st.write('**Size**')
75
+ st.caption(f"width: {items['size'][0].split('x')[0]}, height: {items['size'][0].split('x')[1]}")
76
+ st.write('**Seed**')
77
+ st.caption(f"{items['seed'][0]}")
78
+
79
+ with images:
80
+ selecters = st.columns([1, 1, 2])
81
+ # with selecters[0]:
82
+ with selecters[0]:
83
+ sort_by = st.selectbox('Sort by', items.columns[11: -1])
84
+
85
+ with selecters[1]:
86
+ order = st.selectbox('Order', ['Ascending', 'Descending'], index=1 if sort_by == 'clip_score' or sort_by == 'model_download_count' else 0)
87
+ if order == 'Ascending':
88
+ order = True
89
+ else:
90
+ order = False
91
+
92
+ items = items.sort_values(by=[sort_by], ascending=order).reset_index(drop=True)
93
+ with selecters[2]:
94
+ info = st.multiselect('Show Info',
95
+ ['brisque_score', 'clip_score', 'model_download_count', 'model_name', 'model_id',
96
+ 'modelVersion_name', 'modelVersion_id'],
97
+ default=sort_by)
98
+ # if sort_by not in info:
99
+ # info.append(sort_by)
100
+
101
+ col_num = st.slider('Number of columns', min_value=1, max_value=9, value=4, step=1, key='col_num')
102
+ self.gallery(items, col_num, info)
103
+ # st.write(items)
104
+
105
+
106
+ if __name__ == '__main__':
107
+ login(token=os.environ.get("HF_TOKEN"))
108
+
109
+ if 'roster' not in st.session_state:
110
+ print('loading roster')
111
+ # st.session_state.roster = pd.DataFrame(load_dataset('NYUSHPRP/ModelCofferRoster', split='train'))
112
+ st.session_state.roster = pd.DataFrame(load_from_disk(os.path.join(os.getcwd(), 'data', 'roster')))
113
+ st.session_state.roster = st.session_state.roster[['model_id', 'model_name', 'modelVersion_id', 'modelVersion_name',
114
+ 'model_download_count']].drop_duplicates().reset_index(drop=True)
115
+ # add model download count from roster to promptbook dataframe
116
+ if 'promptBook' not in st.session_state:
117
+ print('loading promptBook')
118
+
119
+ st.session_state.promptBook = pd.DataFrame(load_dataset('NYUSHPRP/ModelCofferMetadata', split='train'))
120
+ st.session_state.images = load_from_disk(os.path.join(os.getcwd(), 'data', 'promptbook'))
121
+ print('images loaded')
122
+ # st.session_state.promptBook = pd.DataFrame(load_dataset('NYUSHPRP/ModelCofferPromptBook', split='train'))
123
+ st.session_state.promptBook = st.session_state.promptBook.merge(st.session_state.roster[['model_id', 'model_name', 'modelVersion_id', 'modelVersion_name', 'model_download_count']], on=['model_id', 'modelVersion_id'], how='left')
124
+
125
+ # add column to record current row index
126
+ st.session_state.promptBook['row_idx'] = st.session_state.promptBook.index
127
+ print('promptBook loaded')
128
+ # print(st.session_state.promptBook)
129
+
130
+ check_roster_error = False
131
+ if check_roster_error:
132
+ # print all rows with the same model_id and modelVersion_id but different model_download_count in roster
133
+ print(st.session_state.roster[st.session_state.roster.duplicated(subset=['model_id', 'modelVersion_id'], keep=False)].sort_values(by=['model_id', 'modelVersion_id']))
134
+
135
+ app = GalleryApp(promptBook=st.session_state.promptBook)
136
+ app.app()
data/download_script.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from datasets import load_dataset, Dataset, load_from_disk
2
+
3
+
4
+ def main():
5
+ promptbook = load_dataset('NYUSHPRP/ModelCofferPromptBook', split='train')
6
+ promptbook.save_to_disk('./promptbook')
7
+
8
+ roster = load_dataset('NYUSHPRP/ModelCofferRoster', split='train')
9
+ roster.save_to_disk('./roster')
10
+
11
+
12
+ def load():
13
+ roster = load_from_disk('./roster')
14
+ print(roster)
15
+
16
+
17
+ def test():
18
+ promptbook = load_from_disk('./promptbook')
19
+ print(promptbook[0]['image'])
20
+
21
+
22
+
23
+ if __name__ == '__main__':
24
+ # main()
25
+ # load()
26
+ test()
data/promptbook/data-00000-of-00010.arrow ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7abd243755b826c29ab6fb46266f135533d93e809833e546f5904d2882d2cc03
3
+ size 473104752
data/promptbook/data-00001-of-00010.arrow ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ff212f5cca342b996acd01be6dcd58fd7cf9f38fb5911b0c1cb088295059640c
3
+ size 465910968
data/promptbook/data-00002-of-00010.arrow ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:780ff259901f6b76eb24fa22d9a8d04c3ffba97337f8b0c6698042d7a1c65665
3
+ size 467081872
data/promptbook/data-00003-of-00010.arrow ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:244f7c5fe9d22b3e0f1860d907769ecc5d5b47c7368ed1adcfe9286eee3acad2
3
+ size 470412576
data/promptbook/data-00004-of-00010.arrow ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:40a8bb4117058db33d04aee01417edbfc31c3c4d5ab676513fdd8c1721524d6a
3
+ size 471499320
data/promptbook/data-00005-of-00010.arrow ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e7a248986cee7eaa81f4f1655c695dd6529d55d010879c771b596ecb8c634c5c
3
+ size 470668704
data/promptbook/data-00006-of-00010.arrow ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d2625acda78f978666df44577de4114e858c9cc93013afcc044b51e368e8357d
3
+ size 466806344
data/promptbook/data-00007-of-00010.arrow ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fee7c9b20d9deb0fea358772d72ca5b4554f901808b3685f90a0794b16a2e42c
3
+ size 468241728
data/promptbook/data-00008-of-00010.arrow ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ab49d30832f279ec60ffeece9fdf89e032c01a0c02378365a601a327699fb7ac
3
+ size 469175856
data/promptbook/data-00009-of-00010.arrow ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f73b02a9dded0a39d705c3c6aec0ba10c0e969fd0f11280895bc702fbfb394da
3
+ size 466882920
data/promptbook/dataset_info.json ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "citation": "",
3
+ "dataset_size": 4689764693,
4
+ "description": "",
5
+ "download_checksums": {
6
+ "https://huggingface.co/datasets/NYUSHPRP/ModelCofferPromptBook/resolve/2c8baf22882145215d258a580b75abf3a27107b1/data/train-00000-of-00010-d9a8d9d4a085684d.parquet": {
7
+ "num_bytes": 472890795,
8
+ "checksum": null
9
+ },
10
+ "https://huggingface.co/datasets/NYUSHPRP/ModelCofferPromptBook/resolve/2c8baf22882145215d258a580b75abf3a27107b1/data/train-00001-of-00010-ee4b84513a1ad2d4.parquet": {
11
+ "num_bytes": 465701779,
12
+ "checksum": null
13
+ },
14
+ "https://huggingface.co/datasets/NYUSHPRP/ModelCofferPromptBook/resolve/2c8baf22882145215d258a580b75abf3a27107b1/data/train-00002-of-00010-7f26e0d02d54bd02.parquet": {
15
+ "num_bytes": 466873748,
16
+ "checksum": null
17
+ },
18
+ "https://huggingface.co/datasets/NYUSHPRP/ModelCofferPromptBook/resolve/2c8baf22882145215d258a580b75abf3a27107b1/data/train-00003-of-00010-d4ca45236306d54b.parquet": {
19
+ "num_bytes": 470202126,
20
+ "checksum": null
21
+ },
22
+ "https://huggingface.co/datasets/NYUSHPRP/ModelCofferPromptBook/resolve/2c8baf22882145215d258a580b75abf3a27107b1/data/train-00004-of-00010-d1bad2a249d12a53.parquet": {
23
+ "num_bytes": 471290759,
24
+ "checksum": null
25
+ },
26
+ "https://huggingface.co/datasets/NYUSHPRP/ModelCofferPromptBook/resolve/2c8baf22882145215d258a580b75abf3a27107b1/data/train-00005-of-00010-eb750f68b3736e3e.parquet": {
27
+ "num_bytes": 470459382,
28
+ "checksum": null
29
+ },
30
+ "https://huggingface.co/datasets/NYUSHPRP/ModelCofferPromptBook/resolve/2c8baf22882145215d258a580b75abf3a27107b1/data/train-00006-of-00010-717c8b796b5738e7.parquet": {
31
+ "num_bytes": 466595911,
32
+ "checksum": null
33
+ },
34
+ "https://huggingface.co/datasets/NYUSHPRP/ModelCofferPromptBook/resolve/2c8baf22882145215d258a580b75abf3a27107b1/data/train-00007-of-00010-61d704caa01de276.parquet": {
35
+ "num_bytes": 468032296,
36
+ "checksum": null
37
+ },
38
+ "https://huggingface.co/datasets/NYUSHPRP/ModelCofferPromptBook/resolve/2c8baf22882145215d258a580b75abf3a27107b1/data/train-00008-of-00010-38eb6fe5f60d6139.parquet": {
39
+ "num_bytes": 468967088,
40
+ "checksum": null
41
+ },
42
+ "https://huggingface.co/datasets/NYUSHPRP/ModelCofferPromptBook/resolve/2c8baf22882145215d258a580b75abf3a27107b1/data/train-00009-of-00010-47ae97f4f60b336a.parquet": {
43
+ "num_bytes": 466675982,
44
+ "checksum": null
45
+ }
46
+ },
47
+ "download_size": 4687689866,
48
+ "features": {
49
+ "image": {
50
+ "_type": "Image"
51
+ },
52
+ "image_id": {
53
+ "dtype": "string",
54
+ "_type": "Value"
55
+ },
56
+ "tag": {
57
+ "dtype": "string",
58
+ "_type": "Value"
59
+ },
60
+ "model_id": {
61
+ "dtype": "int64",
62
+ "_type": "Value"
63
+ },
64
+ "modelVersion_id": {
65
+ "dtype": "int64",
66
+ "_type": "Value"
67
+ },
68
+ "prompt_id": {
69
+ "dtype": "int64",
70
+ "_type": "Value"
71
+ },
72
+ "size": {
73
+ "dtype": "string",
74
+ "_type": "Value"
75
+ },
76
+ "seed": {
77
+ "dtype": "int64",
78
+ "_type": "Value"
79
+ },
80
+ "prompt": {
81
+ "dtype": "string",
82
+ "_type": "Value"
83
+ },
84
+ "negativePrompt": {
85
+ "dtype": "string",
86
+ "_type": "Value"
87
+ },
88
+ "cfgScale": {
89
+ "dtype": "int64",
90
+ "_type": "Value"
91
+ },
92
+ "sampler": {
93
+ "dtype": "string",
94
+ "_type": "Value"
95
+ },
96
+ "brisque_score": {
97
+ "dtype": "float64",
98
+ "_type": "Value"
99
+ },
100
+ "clip_score": {
101
+ "dtype": "float64",
102
+ "_type": "Value"
103
+ }
104
+ },
105
+ "homepage": "",
106
+ "license": "",
107
+ "size_in_bytes": 9377454559,
108
+ "splits": {
109
+ "train": {
110
+ "name": "train",
111
+ "num_bytes": 4689764693,
112
+ "num_examples": 7797,
113
+ "shard_lengths": [
114
+ 1560,
115
+ 1560,
116
+ 1560,
117
+ 1559,
118
+ 1558
119
+ ],
120
+ "dataset_name": "parquet"
121
+ }
122
+ }
123
+ }
data/promptbook/state.json ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_data_files": [
3
+ {
4
+ "filename": "data-00000-of-00010.arrow"
5
+ },
6
+ {
7
+ "filename": "data-00001-of-00010.arrow"
8
+ },
9
+ {
10
+ "filename": "data-00002-of-00010.arrow"
11
+ },
12
+ {
13
+ "filename": "data-00003-of-00010.arrow"
14
+ },
15
+ {
16
+ "filename": "data-00004-of-00010.arrow"
17
+ },
18
+ {
19
+ "filename": "data-00005-of-00010.arrow"
20
+ },
21
+ {
22
+ "filename": "data-00006-of-00010.arrow"
23
+ },
24
+ {
25
+ "filename": "data-00007-of-00010.arrow"
26
+ },
27
+ {
28
+ "filename": "data-00008-of-00010.arrow"
29
+ },
30
+ {
31
+ "filename": "data-00009-of-00010.arrow"
32
+ }
33
+ ],
34
+ "_fingerprint": "f0f128229ec661c4",
35
+ "_format_columns": null,
36
+ "_format_kwargs": {},
37
+ "_format_type": null,
38
+ "_output_all_columns": false,
39
+ "_split": "train"
40
+ }
data/roster/data-00000-of-00001.arrow ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fbaae46cb2963826d3b62bfc6e4877d9e3fee8dab09a0a0c4dde8469e0950b98
3
+ size 94784
data/roster/dataset_info.json ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "citation": "",
3
+ "dataset_size": 93369,
4
+ "description": "",
5
+ "download_checksums": {
6
+ "https://huggingface.co/datasets/NYUSHPRP/ModelCofferRoster/resolve/5ebb9e1dde0260782309d6ebe6328a10d75ecadc/data/train-00000-of-00001-11e8fb473661b208.parquet": {
7
+ "num_bytes": 15443,
8
+ "checksum": null
9
+ }
10
+ },
11
+ "download_size": 15443,
12
+ "features": {
13
+ "tag": {
14
+ "dtype": "string",
15
+ "_type": "Value"
16
+ },
17
+ "model_name": {
18
+ "dtype": "string",
19
+ "_type": "Value"
20
+ },
21
+ "model_id": {
22
+ "dtype": "int64",
23
+ "_type": "Value"
24
+ },
25
+ "modelVersion_name": {
26
+ "dtype": "string",
27
+ "_type": "Value"
28
+ },
29
+ "modelVersion_id": {
30
+ "dtype": "int64",
31
+ "_type": "Value"
32
+ },
33
+ "modelVersion_url": {
34
+ "dtype": "string",
35
+ "_type": "Value"
36
+ },
37
+ "modelVersion_trainedWords": {
38
+ "dtype": "string",
39
+ "_type": "Value"
40
+ },
41
+ "model_download_count": {
42
+ "dtype": "int64",
43
+ "_type": "Value"
44
+ }
45
+ },
46
+ "homepage": "",
47
+ "license": "",
48
+ "size_in_bytes": 108812,
49
+ "splits": {
50
+ "train": {
51
+ "name": "train",
52
+ "num_bytes": 93369,
53
+ "num_examples": 722,
54
+ "dataset_name": "parquet"
55
+ }
56
+ }
57
+ }
data/roster/state.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_data_files": [
3
+ {
4
+ "filename": "data-00000-of-00001.arrow"
5
+ }
6
+ ],
7
+ "_fingerprint": "a937ede09f446dbe",
8
+ "_format_columns": null,
9
+ "_format_kwargs": {},
10
+ "_format_type": null,
11
+ "_output_all_columns": false,
12
+ "_split": "train"
13
+ }
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ huggingface_hub
2
+ streamlit-elements==0.1.0
3
+ streamlit-extras
4
+ altair<5