Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -29,13 +29,16 @@ class APIClient:
|
|
| 29 |
return self._post(f"{self.base_url}/v2/job", json=body)
|
| 30 |
|
| 31 |
|
| 32 |
-
def infer(prompt, seed=42, randomize_seed=False,
|
| 33 |
if randomize_seed:
|
| 34 |
seed = random.randint(0, MAX_SEED)
|
|
|
|
|
|
|
|
|
|
| 35 |
image = generative_api.job({
|
| 36 |
"prompt": prompt,
|
| 37 |
-
"width": width,
|
| 38 |
-
"height": height,
|
| 39 |
"seed": seed,
|
| 40 |
"num_inference_steps": num_inference_steps,
|
| 41 |
"guidance_scale": guidance_scale
|
|
@@ -114,22 +117,14 @@ with gr.Blocks(css=css) as demo:
|
|
| 114 |
|
| 115 |
with gr.Row():
|
| 116 |
|
| 117 |
-
|
| 118 |
-
label="
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
height = gr.Slider(
|
| 127 |
-
label="Height",
|
| 128 |
-
minimum=256,
|
| 129 |
-
maximum=MAX_IMAGE_SIZE,
|
| 130 |
-
step=32,
|
| 131 |
-
value=1024,
|
| 132 |
-
interactive=False
|
| 133 |
)
|
| 134 |
|
| 135 |
with gr.Row():
|
|
@@ -161,7 +156,7 @@ with gr.Blocks(css=css) as demo:
|
|
| 161 |
gr.on(
|
| 162 |
triggers=[run_button.click, prompt.submit],
|
| 163 |
fn = infer,
|
| 164 |
-
inputs = [prompt, seed, randomize_seed,
|
| 165 |
outputs = [result, seed]
|
| 166 |
)
|
| 167 |
|
|
|
|
| 29 |
return self._post(f"{self.base_url}/v2/job", json=body)
|
| 30 |
|
| 31 |
|
| 32 |
+
def infer(prompt, seed=42, randomize_seed=False, resolution="1024x1024", guidance_scale=5.0, num_inference_steps=28, progress=gr.Progress(track_tqdm=True)):
|
| 33 |
if randomize_seed:
|
| 34 |
seed = random.randint(0, MAX_SEED)
|
| 35 |
+
|
| 36 |
+
width, height = resolution.split("x")
|
| 37 |
+
|
| 38 |
image = generative_api.job({
|
| 39 |
"prompt": prompt,
|
| 40 |
+
"width": int(width),
|
| 41 |
+
"height": int(height),
|
| 42 |
"seed": seed,
|
| 43 |
"num_inference_steps": num_inference_steps,
|
| 44 |
"guidance_scale": guidance_scale
|
|
|
|
| 117 |
|
| 118 |
with gr.Row():
|
| 119 |
|
| 120 |
+
resolution = gr.Dropdown(
|
| 121 |
+
label="Resolution",
|
| 122 |
+
value="1024x1024",
|
| 123 |
+
choices=[
|
| 124 |
+
"1024x1024",
|
| 125 |
+
"1024x576",
|
| 126 |
+
"576x1024"
|
| 127 |
+
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
)
|
| 129 |
|
| 130 |
with gr.Row():
|
|
|
|
| 156 |
gr.on(
|
| 157 |
triggers=[run_button.click, prompt.submit],
|
| 158 |
fn = infer,
|
| 159 |
+
inputs = [prompt, seed, randomize_seed, resolution, guidance_scale, num_inference_steps],
|
| 160 |
outputs = [result, seed]
|
| 161 |
)
|
| 162 |
|