Spaces:
Sleeping
Sleeping
fix: duration and input example
Browse files
app.py
CHANGED
|
@@ -74,7 +74,15 @@ def get_examples():
|
|
| 74 |
]
|
| 75 |
return case
|
| 76 |
|
| 77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
def FlowOpt_run(
|
| 79 |
image_src_val: str, model_type_val: str, T_steps_val: int,
|
| 80 |
n_max_val: int, eta_val: float, flowopt_iterations_val: int,
|
|
@@ -159,9 +167,9 @@ with gr.Blocks(css=css) as demo:
|
|
| 159 |
|
| 160 |
with gr.Row():
|
| 161 |
with gr.Column():
|
| 162 |
-
image_src = gr.Image(type="filepath", label="Source Image", value="inputs/
|
| 163 |
-
src_prompt = gr.Textbox(lines=2, label="Source Prompt", value="A
|
| 164 |
-
tar_prompt = gr.Textbox(lines=2, label="Target Prompt", value="A
|
| 165 |
submit_button = gr.Button("Run FlowOpt", variant="primary")
|
| 166 |
|
| 167 |
with gr.Row():
|
|
@@ -169,7 +177,7 @@ with gr.Blocks(css=css) as demo:
|
|
| 169 |
T_steps = gr.Slider(value=15, minimum=10, maximum=50, step=1, label="Total Steps", info="Total number of discretization steps.")
|
| 170 |
n_max = gr.Slider(value=13, minimum=1, maximum=15, step=1, label="n_max", info="Control the strength of the edit.")
|
| 171 |
eta = gr.Slider(value=0.0025, minimum=0.0001, maximum=0.05, label="eta", info="Control the optimization step-size.")
|
| 172 |
-
flowopt_iterations = gr.Number(value=
|
| 173 |
|
| 174 |
with gr.Column():
|
| 175 |
image_tar = gr.Gallery(
|
|
|
|
| 74 |
]
|
| 75 |
return case
|
| 76 |
|
| 77 |
+
def get_duration(*args, **kwargs) -> float:
|
| 78 |
+
model_type_val = kwargs.get("model_type_val", 'FLUX')
|
| 79 |
+
n_max_val = kwargs.get("n_max_val", 15)
|
| 80 |
+
flowopt_iterations_val = kwargs.get("flowopt_iterations_val", 8)
|
| 81 |
+
|
| 82 |
+
step_duration = 1 if model_type_val == 'FLUX' else 0.4
|
| 83 |
+
return (n_max_val * (flowopt_iterations_val + 2) * step_duration) + 40
|
| 84 |
+
|
| 85 |
+
@spaces.GPU(duration=get_duration)
|
| 86 |
def FlowOpt_run(
|
| 87 |
image_src_val: str, model_type_val: str, T_steps_val: int,
|
| 88 |
n_max_val: int, eta_val: float, flowopt_iterations_val: int,
|
|
|
|
| 167 |
|
| 168 |
with gr.Row():
|
| 169 |
with gr.Column():
|
| 170 |
+
image_src = gr.Image(type="filepath", label="Source Image", value="inputs/corgi_walking.png",)
|
| 171 |
+
src_prompt = gr.Textbox(lines=2, label="Source Prompt", value="A cute brown and white dog walking on a sidewalk near a body of water. The dog is wearing a pink vest, adding a touch of color to the scene.")
|
| 172 |
+
tar_prompt = gr.Textbox(lines=2, label="Target Prompt", value="A cute brown and white dog walking on a sidewalk near a body of water. The dog is wearing a pink vest, adding a touch of color to the scene. The dog and sidewalk are constructed entirely out of Lego bricks, showcasing a blocky and geometric appearance.")
|
| 173 |
submit_button = gr.Button("Run FlowOpt", variant="primary")
|
| 174 |
|
| 175 |
with gr.Row():
|
|
|
|
| 177 |
T_steps = gr.Slider(value=15, minimum=10, maximum=50, step=1, label="Total Steps", info="Total number of discretization steps.")
|
| 178 |
n_max = gr.Slider(value=13, minimum=1, maximum=15, step=1, label="n_max", info="Control the strength of the edit.")
|
| 179 |
eta = gr.Slider(value=0.0025, minimum=0.0001, maximum=0.05, label="eta", info="Control the optimization step-size.")
|
| 180 |
+
flowopt_iterations = gr.Number(value=8, minimum=1, maximum=15, label="flowopt_iterations", info="Max number of FlowOpt iterations")
|
| 181 |
|
| 182 |
with gr.Column():
|
| 183 |
image_tar = gr.Gallery(
|