Commit
·
e82dda8
1
Parent(s):
90b0ec3
uP
Browse files- app.py +52 -0
- requirements.txt +2 -0
app.py
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from datasets import load_dataset
|
| 2 |
+
from collections import Counter
|
| 3 |
+
from random import choices, shuffle
|
| 4 |
+
import os
|
| 5 |
+
|
| 6 |
+
parti_prompt_results = []
|
| 7 |
+
ORG = "diffusers-parti-prompts"
|
| 8 |
+
SUBMISSIONS = {
|
| 9 |
+
"Stable Diffusion 1-5": load_dataset(os.path.join(ORG, "sd-v1-5"))["train"],
|
| 10 |
+
# "Stable Diffusion 2-1": load_dataset(os.path.join(ORG, "sd-v2-1")),
|
| 11 |
+
# "IF-1-0": None,
|
| 12 |
+
# "Karlo": None,
|
| 13 |
+
# "Kadinsky":
|
| 14 |
+
}
|
| 15 |
+
NUM_QUESTIONS = 25
|
| 16 |
+
|
| 17 |
+
submission_names = list(SUBMISSIONS.keys())
|
| 18 |
+
num_images = len(SUBMISSIONS[submission_names[0]])
|
| 19 |
+
|
| 20 |
+
def start():
|
| 21 |
+
ids = {id: 0 for id in range(num_images)}
|
| 22 |
+
|
| 23 |
+
# submissions = load_dataset(os.path.join(ORG, "submissions"))
|
| 24 |
+
# submitted_ids = Counter(submissions["ids"])
|
| 25 |
+
submitted_ids = {}
|
| 26 |
+
|
| 27 |
+
ids = {**ids, **submitted_ids}
|
| 28 |
+
|
| 29 |
+
# sort by count
|
| 30 |
+
ids = sorted(ids)
|
| 31 |
+
|
| 32 |
+
# get lowest count ids
|
| 33 |
+
id_candidates = ids[:(8 * NUM_QUESTIONS)]
|
| 34 |
+
|
| 35 |
+
# get random `NUM_QUESTIONS` ids to check
|
| 36 |
+
image_ids = choices(id_candidates, k=NUM_QUESTIONS)
|
| 37 |
+
images = {}
|
| 38 |
+
|
| 39 |
+
for i in range(NUM_QUESTIONS):
|
| 40 |
+
order = list(range(len(SUBMISSIONS)))
|
| 41 |
+
shuffle(order)
|
| 42 |
+
|
| 43 |
+
id = image_ids[i]
|
| 44 |
+
images[i] = {
|
| 45 |
+
"prompt": SUBMISSIONS[submission_names[0]][id]["Prompt"],
|
| 46 |
+
"id": id,
|
| 47 |
+
"choices": {i: SUBMISSIONS[submission_names[i]][id]["images"] for i in order},
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
return images
|
| 51 |
+
|
| 52 |
+
hello = start()
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
requests
|
| 2 |
+
datasets
|