update
Browse files
app.py
CHANGED
@@ -10,11 +10,9 @@ EXAMPLES_DIR = os.path.abspath("./examples")
|
|
10 |
def generate_images(prompt, init_pop, total_itrs):
|
11 |
init_pop = int(init_pop)
|
12 |
total_itrs = int(total_itrs)
|
13 |
-
|
14 |
# Use placeholder if prompt is empty
|
15 |
if not prompt.strip():
|
16 |
prompt = "a duck crossing the street"
|
17 |
-
|
18 |
archive_plots = []
|
19 |
for archive, plt_fig in run_qdhf(prompt, init_pop, total_itrs):
|
20 |
buf = io.BytesIO()
|
@@ -36,14 +34,15 @@ def generate_images(prompt, init_pop, total_itrs):
|
|
36 |
|
37 |
return temp_archive_file, temp_images_file
|
38 |
|
39 |
-
def show_example(
|
40 |
-
index = EXAMPLE_PROMPTS.index(
|
41 |
archive_plot_path = os.path.join(EXAMPLES_DIR, f"archive_{index}.mp4")
|
42 |
images_path = os.path.join(EXAMPLES_DIR, f"archive_pics_{index}.png")
|
43 |
-
return archive_plot_path, images_path
|
44 |
|
45 |
with gr.Blocks() as demo:
|
46 |
gr.Markdown("# Quality Diversity through Human Feedback")
|
|
|
47 |
|
48 |
with gr.Row():
|
49 |
with gr.Column(scale=1):
|
@@ -60,10 +59,14 @@ with gr.Blocks() as demo:
|
|
60 |
inputs=[prompt_input, init_pop, total_itrs],
|
61 |
outputs=[archive_output, images_output])
|
62 |
|
63 |
-
gr.
|
64 |
-
|
65 |
-
|
66 |
-
|
|
|
|
|
|
|
|
|
67 |
|
68 |
if __name__ == "__main__":
|
69 |
demo.launch()
|
|
|
10 |
def generate_images(prompt, init_pop, total_itrs):
|
11 |
init_pop = int(init_pop)
|
12 |
total_itrs = int(total_itrs)
|
|
|
13 |
# Use placeholder if prompt is empty
|
14 |
if not prompt.strip():
|
15 |
prompt = "a duck crossing the street"
|
|
|
16 |
archive_plots = []
|
17 |
for archive, plt_fig in run_qdhf(prompt, init_pop, total_itrs):
|
18 |
buf = io.BytesIO()
|
|
|
34 |
|
35 |
return temp_archive_file, temp_images_file
|
36 |
|
37 |
+
def show_example(prompt):
|
38 |
+
index = EXAMPLE_PROMPTS.index(prompt)
|
39 |
archive_plot_path = os.path.join(EXAMPLES_DIR, f"archive_{index}.mp4")
|
40 |
images_path = os.path.join(EXAMPLES_DIR, f"archive_pics_{index}.png")
|
41 |
+
return prompt, archive_plot_path, images_path
|
42 |
|
43 |
with gr.Blocks() as demo:
|
44 |
gr.Markdown("# Quality Diversity through Human Feedback")
|
45 |
+
gr.Markdown("[Paper](https://arxiv.org/abs/2310.12103) | [Project Website](https://liding.info/qdhf/)")
|
46 |
|
47 |
with gr.Row():
|
48 |
with gr.Column(scale=1):
|
|
|
59 |
inputs=[prompt_input, init_pop, total_itrs],
|
60 |
outputs=[archive_output, images_output])
|
61 |
|
62 |
+
gr.Examples(
|
63 |
+
examples=EXAMPLE_PROMPTS,
|
64 |
+
inputs=prompt_input,
|
65 |
+
outputs=[prompt_input, archive_output, images_output],
|
66 |
+
fn=show_example,
|
67 |
+
cache_examples=True,
|
68 |
+
label="Example Prompts"
|
69 |
+
)
|
70 |
|
71 |
if __name__ == "__main__":
|
72 |
demo.launch()
|