|
|
import gradio as gr |
|
|
|
|
|
global selected_prompt |
|
|
|
|
|
|
|
|
def greet(name): |
|
|
return "Hello " + name + "!" |
|
|
|
|
|
|
|
|
def reload_images(prompt): |
|
|
image_A = "https://picsum.photos/seed/picsum/512/512" |
|
|
image_B = "https://picsum.photos/seed/picsum/512/512" |
|
|
return image_A, image_B |
|
|
|
|
|
|
|
|
def set_image_A_better(): |
|
|
print('set_image_A_better clicked') |
|
|
pass |
|
|
|
|
|
|
|
|
def set_image_B_better(): |
|
|
print('set_image_B_better clicked') |
|
|
pass |
|
|
|
|
|
|
|
|
def on_prompt_change(prompt): |
|
|
print(f'on_prompt_change -> {prompt=}') |
|
|
global selected_prompt |
|
|
selected_prompt = prompt |
|
|
|
|
|
|
|
|
prompt_choices = ["Hello", "Goodbye"] |
|
|
|
|
|
with gr.Blocks() as demo: |
|
|
with gr.Row() as input_prompt: |
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|
with gr.Row() as image_pair: |
|
|
with gr.Column() as image_A: |
|
|
image_A = gr.Image( |
|
|
height=512, width=512, |
|
|
label="Image A", |
|
|
value="img1A_512x512.jpg", |
|
|
interactive=False) |
|
|
with gr.Row(): |
|
|
bt_image_A_better = gr.Button(value="Left image is better") |
|
|
bt_image_A_better.click(set_image_A_better) |
|
|
|
|
|
with gr.Column(min_width=512) as image_B: |
|
|
image_B = gr.Image( |
|
|
height=512, width=512, |
|
|
label="Image B", |
|
|
value="img1A_512x512.jpg", |
|
|
interactive=False |
|
|
) |
|
|
with gr.Row(): |
|
|
bt_image_B_better = gr.Button(value="Right image is better",) |
|
|
bt_image_B_better.click(set_image_B_better) |
|
|
|
|
|
if __name__ == "__main__": |
|
|
demo.launch(show_api=False) |
|
|
|