Add examples
Browse files- edit_app.py +16 -0
edit_app.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
from __future__ import annotations
|
| 2 |
|
| 3 |
import math
|
|
|
|
| 4 |
import random
|
| 5 |
|
| 6 |
import gradio as gr
|
|
@@ -113,6 +114,10 @@ def reset():
|
|
| 113 |
return [0, "Randomize Seed", 1371, "Fix CFG", 7.5, 1.5, None]
|
| 114 |
|
| 115 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
with gr.Blocks() as demo:
|
| 117 |
gr.HTML(
|
| 118 |
"""<h1 style="font-weight: 900; margin-bottom: 7px;">
|
|
@@ -160,6 +165,17 @@ InstructPix2Pix: Learning to Follow Image Editing Instructions
|
|
| 160 |
text_cfg_scale = gr.Number(value=7.5, label="Text CFG", interactive=True)
|
| 161 |
image_cfg_scale = gr.Number(value=1.5, label="Image CFG", interactive=True)
|
| 162 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 163 |
gr.Markdown(help_text)
|
| 164 |
|
| 165 |
load_button.click(
|
|
|
|
| 1 |
from __future__ import annotations
|
| 2 |
|
| 3 |
import math
|
| 4 |
+
import os
|
| 5 |
import random
|
| 6 |
|
| 7 |
import gradio as gr
|
|
|
|
| 114 |
return [0, "Randomize Seed", 1371, "Fix CFG", 7.5, 1.5, None]
|
| 115 |
|
| 116 |
|
| 117 |
+
def process_example(input_image: Image.Image, instruction: str, seed: int) -> Image.Image:
|
| 118 |
+
return generate(input_image, instruction, 50, False, seed, False, 7.5, 1.5)[-1]
|
| 119 |
+
|
| 120 |
+
|
| 121 |
with gr.Blocks() as demo:
|
| 122 |
gr.HTML(
|
| 123 |
"""<h1 style="font-weight: 900; margin-bottom: 7px;">
|
|
|
|
| 165 |
text_cfg_scale = gr.Number(value=7.5, label="Text CFG", interactive=True)
|
| 166 |
image_cfg_scale = gr.Number(value=1.5, label="Image CFG", interactive=True)
|
| 167 |
|
| 168 |
+
gr.Examples(
|
| 169 |
+
examples=[
|
| 170 |
+
["imgs/example.jpg", "Turn him into a cyborg", 0],
|
| 171 |
+
["imgs/example.jpg", "Have him smile", 0],
|
| 172 |
+
],
|
| 173 |
+
inputs=[input_image, instruction, seed],
|
| 174 |
+
outputs=edited_image,
|
| 175 |
+
fn=process_example,
|
| 176 |
+
cache_examples=os.getenv("CACHE_EXAMPLES") == "1",
|
| 177 |
+
)
|
| 178 |
+
|
| 179 |
gr.Markdown(help_text)
|
| 180 |
|
| 181 |
load_button.click(
|