Spaces:
Paused
Paused
File size: 3,382 Bytes
59f949f c5a321b 59f949f c5a321b 59f949f 053ae38 59f949f 053ae38 59f949f 053ae38 59f949f 91cb807 8b04feb 91cb807 59f949f 053ae38 59f949f 053ae38 59f949f 053ae38 59f949f 053ae38 59f949f 053ae38 59f949f 053ae38 59f949f 053ae38 59f949f 053ae38 59f949f 053ae38 d63526a 7c75445 59f949f 053ae38 59f949f 91cb807 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
from __future__ import annotations
import gradio as gr
# import spaces
from PIL import Image
import torch
from my_run import run as run_model
# @spaces.GPU
def main_pipeline(
input_image: str,
src_prompt: str,
tgt_prompt: str,
seed: int,
w1: float,
# w2: float,
):
w2 = 1.0
res_image = run_model(input_image, src_prompt, tgt_prompt, seed, w1, w2)
return res_image
with gr.Blocks(css="app/style.css", theme="Nymbo/Nymbo_Theme") as demo:
gr.HTML("<center><h1>Turbo Edit</h1></center>")
with gr.Row():
with gr.Column():
input_image = gr.Image(
label="Input image", type="filepath", height=512, width=512
)
src_prompt = gr.Text(
label="Source Prompt",
max_lines=1,
placeholder="Source Prompt",
)
tgt_prompt = gr.Text(
label="Target Prompt",
max_lines=1,
placeholder="Target Prompt",
)
with gr.Accordion("Advanced Options", open=False):
seed = gr.Slider(
label="seed", minimum=0, maximum=16 * 1024, value=7865, step=1
)
w1 = gr.Slider(
label="w", minimum=1.0, maximum=3.0, value=1.5, step=0.05
)
# w2 = gr.Slider(
# label='w2',
# minimum=1.0,
# maximum=3.0,
# value=1.0,
# step=0.05
# )
run_button = gr.Button("Edit")
with gr.Column():
# result = gr.Gallery(label='Result')
result = gr.Image(label="Result", type="pil", height=512, width=512)
examples = [
[
"examples_demo/1.jpeg", # input_image
"a dreamy cat sleeping on a floating leaf", # src_prompt
"a dreamy bear sleeping on a floating leaf", # tgt_prompt
7, # seed
1.3, # w1
],
[
"examples_demo/2.jpeg", # input_image
"A painting of a cat and a bunny surrounded by flowers", # src_prompt
"a polygonal illustration of a cat and a bunny", # tgt_prompt
2, # seed
1.5, # w1
],
[
"examples_demo/3.jpg", # input_image
"a chess pawn wearing a crown", # src_prompt
"a chess pawn wearing a hat", # tgt_prompt
2, # seed
1.3, # w1
],
]
gr.Examples(
examples=examples,
inputs=[
input_image,
src_prompt,
tgt_prompt,
seed,
w1,
],
outputs=[result],
fn=main_pipeline,
cache_examples=True,
)
inputs = [
input_image,
src_prompt,
tgt_prompt,
seed,
w1,
# w2,
]
outputs = [result]
run_button.click(fn=main_pipeline, inputs=inputs, outputs=outputs)
demo.queue(max_size=50).launch(share=False) |