Spaces:
Build error
Build error
Upload folder using huggingface_hub
Browse files- .gitattributes +1 -0
- README.md +3 -9
- __pycache__/app.cpython-310.pyc +0 -0
- app.py +124 -0
- gen_images/baseline/sommerhus (2).png +0 -0
- gen_images/lora/sommerhus (3).png +0 -0
- notes.txt +12 -0
- og_images/sommerhus_original.jpg +3 -0
- results.txt +0 -0
- votes.json +1 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
og_images/sommerhus_original.jpg filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
|
@@ -1,12 +1,6 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji: π»
|
| 4 |
-
colorFrom: gray
|
| 5 |
-
colorTo: indigo
|
| 6 |
-
sdk: gradio
|
| 7 |
-
sdk_version: 4.19.2
|
| 8 |
app_file: app.py
|
| 9 |
-
|
|
|
|
| 10 |
---
|
| 11 |
-
|
| 12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
+
title: voting_kitchens
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
app_file: app.py
|
| 4 |
+
sdk: gradio
|
| 5 |
+
sdk_version: 3.36.1
|
| 6 |
---
|
|
|
|
|
|
__pycache__/app.cpython-310.pyc
ADDED
|
Binary file (3.56 kB). View file
|
|
|
app.py
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
|
| 3 |
+
import os
|
| 4 |
+
import json
|
| 5 |
+
from filelock import Timeout, FileLock
|
| 6 |
+
from random import sample, choice
|
| 7 |
+
|
| 8 |
+
def random_images(gen_images):
|
| 9 |
+
return choice(gen_images)
|
| 10 |
+
|
| 11 |
+
def vote(method):
|
| 12 |
+
lock_path = "votes.lock"
|
| 13 |
+
file_path = "votes.json"
|
| 14 |
+
lock = FileLock(lock_path, timeout=10)
|
| 15 |
+
|
| 16 |
+
with lock:
|
| 17 |
+
# Check if the votes file exists, create if not
|
| 18 |
+
if not os.path.exists(file_path):
|
| 19 |
+
with open(file_path, 'w') as file:
|
| 20 |
+
json.dump({}, file)
|
| 21 |
+
|
| 22 |
+
# Read the current votes
|
| 23 |
+
with open(file_path, 'r') as file:
|
| 24 |
+
votes = json.load(file)
|
| 25 |
+
|
| 26 |
+
# Update the vote count
|
| 27 |
+
try:
|
| 28 |
+
option = (method)
|
| 29 |
+
if option in votes:
|
| 30 |
+
votes[option] += 1
|
| 31 |
+
else:
|
| 32 |
+
votes[option] = 1
|
| 33 |
+
except:
|
| 34 |
+
return "Error"
|
| 35 |
+
# Write the updated votes back to the file
|
| 36 |
+
with open(file_path, 'w') as file:
|
| 37 |
+
json.dump(votes, file)
|
| 38 |
+
|
| 39 |
+
def vote_fn(method):
|
| 40 |
+
vote(method)
|
| 41 |
+
image_1, image_2, first_method, second_method = refresh()
|
| 42 |
+
return image_1, image_2, first_method, second_method
|
| 43 |
+
|
| 44 |
+
css = """
|
| 45 |
+
.gradio-container {
|
| 46 |
+
width: 50%; /* Set the width of the container to 50% of the parent element */
|
| 47 |
+
margin-left: auto; /* Set the left margin to auto to enable horizontal centering */
|
| 48 |
+
margin-right: auto;/* Set the right margin to auto to enable horizontal centering */
|
| 49 |
+
}
|
| 50 |
+
.gen_images {
|
| 51 |
+
padding: 30px;
|
| 52 |
+
}
|
| 53 |
+
"""
|
| 54 |
+
|
| 55 |
+
METHODS = ["baseline", "lora"]
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
baseline_imgs = [f"gen_images/baseline/{path}" for path in os.listdir("gen_images/baseline")]
|
| 59 |
+
lora_imgs = [f"gen_images/lora/{path}" for path in os.listdir("gen_images/lora")]
|
| 60 |
+
|
| 61 |
+
og_images = [os.path.join("og_images", path) for path in os.listdir("og_images")]
|
| 62 |
+
|
| 63 |
+
print(baseline_imgs)
|
| 64 |
+
|
| 65 |
+
def refresh():
|
| 66 |
+
random_baseline_img = random_images(baseline_imgs)
|
| 67 |
+
random_lora_img = random_images(lora_imgs)
|
| 68 |
+
|
| 69 |
+
first_method = choice(METHODS)
|
| 70 |
+
|
| 71 |
+
if first_method == "baseline":
|
| 72 |
+
image1 = random_baseline_img
|
| 73 |
+
image2 = random_lora_img
|
| 74 |
+
second_method = "lora"
|
| 75 |
+
else:
|
| 76 |
+
image1 = random_lora_img
|
| 77 |
+
image2 = random_baseline_img
|
| 78 |
+
second_method = "baseline"
|
| 79 |
+
|
| 80 |
+
return image1, image2, first_method, second_method
|
| 81 |
+
|
| 82 |
+
with gr.Blocks(css=css) as demo:
|
| 83 |
+
first_method = gr.State()
|
| 84 |
+
first_method.value = "baseline"
|
| 85 |
+
second_method = gr.State()
|
| 86 |
+
second_method.value = "lora"
|
| 87 |
+
|
| 88 |
+
# show the title of the demo
|
| 89 |
+
gr.components.HTML("<h1>Image Scoring</h1>")
|
| 90 |
+
|
| 91 |
+
# show the description of the demo
|
| 92 |
+
gr.components.HTML("<p>Select the best image among the proposed.</p>")
|
| 93 |
+
|
| 94 |
+
# show the images to be scored on the same row
|
| 95 |
+
with gr.Blocks() as selection:
|
| 96 |
+
with gr.Row(scale=3):
|
| 97 |
+
|
| 98 |
+
random_baseline_img = random_images(baseline_imgs)
|
| 99 |
+
random_lora_img = random_images(lora_imgs)
|
| 100 |
+
|
| 101 |
+
with gr.Row(scale=6, elem_id="gen_images"):
|
| 102 |
+
if first_method.value == "baseline":
|
| 103 |
+
|
| 104 |
+
with gr.Column(scale=6):
|
| 105 |
+
image_1 = gr.Image(random_baseline_img, container=False, show_label=False)
|
| 106 |
+
button1 = gr.Button(value="First Image π")
|
| 107 |
+
with gr.Column(scale=6):
|
| 108 |
+
image_2 = gr.Image(random_lora_img, container=False, show_label=False)
|
| 109 |
+
button2 = gr.Button(value="Second Image π")
|
| 110 |
+
|
| 111 |
+
else:
|
| 112 |
+
with gr.Column(scale=6):
|
| 113 |
+
image_1 = gr.Image(random_baseline_img, container=False, show_label=False)
|
| 114 |
+
button1 = gr.Button(value="First Image π")
|
| 115 |
+
with gr.Column(scale=6):
|
| 116 |
+
image_2 = gr.Image(random_lora_img, container=False, show_label=False)
|
| 117 |
+
button2 = gr.Button(value="Second Image π")
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
button1.click(vote_fn, inputs=[first_method], outputs=[image_1, image_2, first_method, second_method])
|
| 121 |
+
button2.click(vote_fn, inputs=[second_method], outputs=[image_1, image_2, first_method, second_method])
|
| 122 |
+
|
| 123 |
+
|
| 124 |
+
demo.launch(share=True)
|
gen_images/baseline/sommerhus (2).png
ADDED
|
gen_images/lora/sommerhus (3).png
ADDED
|
notes.txt
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
folder structure:
|
| 2 |
+
|
| 3 |
+
- gen_images
|
| 4 |
+
1_seed_method_1
|
| 5 |
+
1_seed_method_2
|
| 6 |
+
|
| 7 |
+
- og_images:
|
| 8 |
+
1
|
| 9 |
+
2
|
| 10 |
+
3
|
| 11 |
+
|
| 12 |
+
- results:
|
og_images/sommerhus_original.jpg
ADDED
|
Git LFS Details
|
results.txt
ADDED
|
File without changes
|
votes.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"baseline": 1, "lora": 1}
|