George Rey
commited on
Commit
·
405d4df
0
Parent(s):
init
Browse files- .gitignore +2 -0
- app.py +64 -0
.gitignore
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.idea
|
| 2 |
+
|
app.py
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import numpy
|
| 3 |
+
import numpy.random
|
| 4 |
+
rng = numpy.random.default_rng()
|
| 5 |
+
|
| 6 |
+
global selected_prompt
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
def greet(name):
|
| 10 |
+
return "Hello " + name + "!"
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
def reload_images(prompt):
|
| 14 |
+
image_A = "https://picsum.photos/seed/picsum/512/512"
|
| 15 |
+
image_B = "https://picsum.photos/seed/picsum/512/512"
|
| 16 |
+
return image_A, image_B
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
def set_image_A_better():
|
| 20 |
+
print('set_image_A_better clicked')
|
| 21 |
+
pass
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def set_image_B_better():
|
| 25 |
+
print('set_image_B_better clicked')
|
| 26 |
+
pass
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def on_prompt_change(prompt):
|
| 30 |
+
print(f'on_prompt_change -> {prompt=}')
|
| 31 |
+
global selected_prompt
|
| 32 |
+
selected_prompt = prompt
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
prompt_choices = ["Hello", "Goodbye"]
|
| 36 |
+
|
| 37 |
+
with gr.Blocks() as demo:
|
| 38 |
+
with gr.Row() as input_prompt:
|
| 39 |
+
pass
|
| 40 |
+
# prompt_input = gr.Dropdown(value="Hello", choices=prompt_choices, label="Select prompt from dropdown")
|
| 41 |
+
# prompt_input.change(on_prompt_change, inputs=prompt_input)
|
| 42 |
+
|
| 43 |
+
with gr.Row() as image_pair:
|
| 44 |
+
with gr.Column() as image_A:
|
| 45 |
+
image_A = gr.Image(
|
| 46 |
+
shape=(512, 512),
|
| 47 |
+
label="Image A",
|
| 48 |
+
value="https://picsum.photos/seed/4/512/512",
|
| 49 |
+
interactive = False)
|
| 50 |
+
bt_image_A_better = gr.Button(value="Left image is better", label="Image A is better", )
|
| 51 |
+
bt_image_A_better.click(set_image_A_better)
|
| 52 |
+
|
| 53 |
+
with gr.Column() as image_B:
|
| 54 |
+
image_B = gr.Image(
|
| 55 |
+
shape=(512, 512),
|
| 56 |
+
label="Image B",
|
| 57 |
+
value="https://picsum.photos/seed/4/512/512/?blur=2",
|
| 58 |
+
interactive = False
|
| 59 |
+
)
|
| 60 |
+
bt_image_B_better = gr.Button(value="Right image is better", label="Image B is better")
|
| 61 |
+
bt_image_B_better.click(set_image_B_better)
|
| 62 |
+
|
| 63 |
+
if __name__ == "__main__":
|
| 64 |
+
demo.launch(show_api=False)
|