Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -30,12 +30,9 @@ def pixelate(input_file_path, pixel_size):
|
|
| 30 |
|
| 31 |
def generate(
|
| 32 |
prompt: str,
|
|
|
|
| 33 |
negative_prompt: str = "",
|
| 34 |
-
prompt_2: str = "",
|
| 35 |
-
negative_prompt_2: str = "",
|
| 36 |
use_negative_prompt: bool = False,
|
| 37 |
-
use_prompt_2: bool = False,
|
| 38 |
-
use_negative_prompt_2: bool = False,
|
| 39 |
seed: int = 0,
|
| 40 |
width: int = 1024,
|
| 41 |
height: int = 1024,
|
|
@@ -46,15 +43,18 @@ def generate(
|
|
| 46 |
apply_refiner: bool = False,
|
| 47 |
pixel_size: int = 16
|
| 48 |
):
|
|
|
|
|
|
|
|
|
|
| 49 |
client = Client("hysts/SDXL")
|
| 50 |
result = client.predict(
|
| 51 |
-
prompt=
|
| 52 |
negative_prompt=negative_prompt,
|
| 53 |
-
prompt_2=
|
| 54 |
-
negative_prompt_2=
|
| 55 |
use_negative_prompt=use_negative_prompt,
|
| 56 |
-
use_prompt_2=
|
| 57 |
-
use_negative_prompt_2=
|
| 58 |
seed=seed,
|
| 59 |
width=width,
|
| 60 |
height=height,
|
|
@@ -77,14 +77,9 @@ examples = [
|
|
| 77 |
|
| 78 |
with gr.Blocks(css="style.css") as demo:
|
| 79 |
gr.Markdown(DESCRIPTION)
|
| 80 |
-
gr.DuplicateButton(
|
| 81 |
-
value="Duplicate Space for private use",
|
| 82 |
-
elem_id="duplicate-button",
|
| 83 |
-
visible=os.getenv("SHOW_DUPLICATE_BUTTON") == "1",
|
| 84 |
-
)
|
| 85 |
with gr.Group():
|
| 86 |
with gr.Row():
|
| 87 |
-
prompt = gr.
|
| 88 |
label="Prompt",
|
| 89 |
show_label=False,
|
| 90 |
max_lines=1,
|
|
@@ -94,30 +89,21 @@ with gr.Blocks(css="style.css") as demo:
|
|
| 94 |
run_button = gr.Button("Run", scale=0)
|
| 95 |
result = gr.Image(label="Result", show_label=False)
|
| 96 |
with gr.Accordion("Advanced options", open=False):
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
use_prompt_2 = gr.Checkbox(label="Use prompt 2", value=False)
|
| 100 |
-
use_negative_prompt_2 = gr.Checkbox(label="Use negative prompt 2", value=False)
|
| 101 |
-
negative_prompt = gr.Text(
|
| 102 |
label="Negative prompt",
|
| 103 |
max_lines=1,
|
| 104 |
placeholder="Enter a negative prompt",
|
| 105 |
visible=True,
|
| 106 |
value="(deformed eyes, nose, ears, nose), bad anatomy, ugly",
|
| 107 |
)
|
| 108 |
-
|
| 109 |
-
label="
|
| 110 |
-
max_lines=1,
|
| 111 |
-
placeholder="Enter your prompt",
|
| 112 |
-
visible=False,
|
| 113 |
-
)
|
| 114 |
-
negative_prompt_2 = gr.Text(
|
| 115 |
-
label="Negative prompt 2",
|
| 116 |
max_lines=1,
|
| 117 |
-
placeholder="Enter
|
| 118 |
-
visible=
|
|
|
|
| 119 |
)
|
| 120 |
-
|
| 121 |
seed = gr.Slider(
|
| 122 |
label="Seed",
|
| 123 |
minimum=0,
|
|
@@ -186,7 +172,6 @@ with gr.Blocks(css="style.css") as demo:
|
|
| 186 |
outputs=result,
|
| 187 |
fn=generate,
|
| 188 |
)
|
| 189 |
-
|
| 190 |
use_negative_prompt.change(
|
| 191 |
fn=lambda x: gr.update(visible=x),
|
| 192 |
inputs=use_negative_prompt,
|
|
@@ -194,20 +179,6 @@ with gr.Blocks(css="style.css") as demo:
|
|
| 194 |
queue=False,
|
| 195 |
api_name=False,
|
| 196 |
)
|
| 197 |
-
use_prompt_2.change(
|
| 198 |
-
fn=lambda x: gr.update(visible=x),
|
| 199 |
-
inputs=use_prompt_2,
|
| 200 |
-
outputs=prompt_2,
|
| 201 |
-
queue=False,
|
| 202 |
-
api_name=False,
|
| 203 |
-
)
|
| 204 |
-
use_negative_prompt_2.change(
|
| 205 |
-
fn=lambda x: gr.update(visible=x),
|
| 206 |
-
inputs=use_negative_prompt_2,
|
| 207 |
-
outputs=negative_prompt_2,
|
| 208 |
-
queue=False,
|
| 209 |
-
api_name=False,
|
| 210 |
-
)
|
| 211 |
apply_refiner.change(
|
| 212 |
fn=lambda x: gr.update(visible=x),
|
| 213 |
inputs=apply_refiner,
|
|
@@ -219,9 +190,8 @@ with gr.Blocks(css="style.css") as demo:
|
|
| 219 |
gr.on(
|
| 220 |
triggers=[
|
| 221 |
prompt.submit,
|
|
|
|
| 222 |
negative_prompt.submit,
|
| 223 |
-
prompt_2.submit,
|
| 224 |
-
negative_prompt_2.submit,
|
| 225 |
run_button.click,
|
| 226 |
],
|
| 227 |
fn=randomize_seed_fn,
|
|
@@ -233,12 +203,9 @@ with gr.Blocks(css="style.css") as demo:
|
|
| 233 |
fn=generate,
|
| 234 |
inputs=[
|
| 235 |
prompt,
|
|
|
|
| 236 |
negative_prompt,
|
| 237 |
-
prompt_2,
|
| 238 |
-
negative_prompt_2,
|
| 239 |
use_negative_prompt,
|
| 240 |
-
use_prompt_2,
|
| 241 |
-
use_negative_prompt_2,
|
| 242 |
seed,
|
| 243 |
width,
|
| 244 |
height,
|
|
|
|
| 30 |
|
| 31 |
def generate(
|
| 32 |
prompt: str,
|
| 33 |
+
additional_prompt: str = "",
|
| 34 |
negative_prompt: str = "",
|
|
|
|
|
|
|
| 35 |
use_negative_prompt: bool = False,
|
|
|
|
|
|
|
| 36 |
seed: int = 0,
|
| 37 |
width: int = 1024,
|
| 38 |
height: int = 1024,
|
|
|
|
| 43 |
apply_refiner: bool = False,
|
| 44 |
pixel_size: int = 16
|
| 45 |
):
|
| 46 |
+
if additional_prompt != "":
|
| 47 |
+
additional_prompt += ", "
|
| 48 |
+
|
| 49 |
client = Client("hysts/SDXL")
|
| 50 |
result = client.predict(
|
| 51 |
+
prompt=additional_prompt+prompt,
|
| 52 |
negative_prompt=negative_prompt,
|
| 53 |
+
prompt_2="",
|
| 54 |
+
negative_prompt_2="",
|
| 55 |
use_negative_prompt=use_negative_prompt,
|
| 56 |
+
use_prompt_2=False,
|
| 57 |
+
use_negative_prompt_2=False,
|
| 58 |
seed=seed,
|
| 59 |
width=width,
|
| 60 |
height=height,
|
|
|
|
| 77 |
|
| 78 |
with gr.Blocks(css="style.css") as demo:
|
| 79 |
gr.Markdown(DESCRIPTION)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
with gr.Group():
|
| 81 |
with gr.Row():
|
| 82 |
+
prompt = gr.Textbox(
|
| 83 |
label="Prompt",
|
| 84 |
show_label=False,
|
| 85 |
max_lines=1,
|
|
|
|
| 89 |
run_button = gr.Button("Run", scale=0)
|
| 90 |
result = gr.Image(label="Result", show_label=False)
|
| 91 |
with gr.Accordion("Advanced options", open=False):
|
| 92 |
+
use_negative_prompt = gr.Checkbox(label="Use negative prompt", value=True)
|
| 93 |
+
negative_prompt = gr.Textbox(
|
|
|
|
|
|
|
|
|
|
| 94 |
label="Negative prompt",
|
| 95 |
max_lines=1,
|
| 96 |
placeholder="Enter a negative prompt",
|
| 97 |
visible=True,
|
| 98 |
value="(deformed eyes, nose, ears, nose), bad anatomy, ugly",
|
| 99 |
)
|
| 100 |
+
additional_prompt = gr.Textbox(
|
| 101 |
+
label="Additional prompt",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
max_lines=1,
|
| 103 |
+
placeholder="Enter an additional prompt",
|
| 104 |
+
visible=True,
|
| 105 |
+
value="((pixelart)), ((retro illustration)), bit games, 8-bit illustration, pixelated",
|
| 106 |
)
|
|
|
|
| 107 |
seed = gr.Slider(
|
| 108 |
label="Seed",
|
| 109 |
minimum=0,
|
|
|
|
| 172 |
outputs=result,
|
| 173 |
fn=generate,
|
| 174 |
)
|
|
|
|
| 175 |
use_negative_prompt.change(
|
| 176 |
fn=lambda x: gr.update(visible=x),
|
| 177 |
inputs=use_negative_prompt,
|
|
|
|
| 179 |
queue=False,
|
| 180 |
api_name=False,
|
| 181 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
apply_refiner.change(
|
| 183 |
fn=lambda x: gr.update(visible=x),
|
| 184 |
inputs=apply_refiner,
|
|
|
|
| 190 |
gr.on(
|
| 191 |
triggers=[
|
| 192 |
prompt.submit,
|
| 193 |
+
additional_prompt.submit,
|
| 194 |
negative_prompt.submit,
|
|
|
|
|
|
|
| 195 |
run_button.click,
|
| 196 |
],
|
| 197 |
fn=randomize_seed_fn,
|
|
|
|
| 203 |
fn=generate,
|
| 204 |
inputs=[
|
| 205 |
prompt,
|
| 206 |
+
additional_prompt,
|
| 207 |
negative_prompt,
|
|
|
|
|
|
|
| 208 |
use_negative_prompt,
|
|
|
|
|
|
|
| 209 |
seed,
|
| 210 |
width,
|
| 211 |
height,
|