Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -115,7 +115,7 @@ def generate_images_30(prompt, neg_prompt_1, neg_prompt_2, neg_prompt_3, width,
|
|
| 115 |
upscale = upscaler_2(sd_image, tiling=True, tile_width=256, tile_height=256)
|
| 116 |
upscale2 = upscaler_2(upscale, tiling=True, tile_width=256, tile_height=256)
|
| 117 |
print('-- got upscaled image --')
|
| 118 |
-
downscaled_upscale = upscale2.resize((upscale2.width //
|
| 119 |
return sd_image, downscaled_upscale, prompt
|
| 120 |
|
| 121 |
@spaces.GPU(duration=70)
|
|
@@ -135,11 +135,11 @@ def generate_images_60(prompt, neg_prompt_1, neg_prompt_2, neg_prompt_3, width,
|
|
| 135 |
upscale = upscaler_2(sd_image, tiling=True, tile_width=256, tile_height=256)
|
| 136 |
upscale2 = upscaler_2(upscale, tiling=True, tile_width=256, tile_height=256)
|
| 137 |
print('-- got upscaled image --')
|
| 138 |
-
downscaled_upscale = upscale2.resize((upscale2.width //
|
| 139 |
return sd_image, downscaled_upscale, prompt
|
| 140 |
|
| 141 |
-
@spaces.GPU(duration=
|
| 142 |
-
def
|
| 143 |
seed = random.randint(0, MAX_SEED)
|
| 144 |
generator = torch.Generator(device=device).manual_seed(seed)
|
| 145 |
print('-- generating image --')
|
|
@@ -155,7 +155,7 @@ def generate_images_100(prompt, neg_prompt_1, neg_prompt_2, neg_prompt_3, width,
|
|
| 155 |
upscale = upscaler_2(sd_image, tiling=True, tile_width=256, tile_height=256)
|
| 156 |
upscale2 = upscaler_2(upscale, tiling=True, tile_width=256, tile_height=256)
|
| 157 |
print('-- got upscaled image --')
|
| 158 |
-
downscaled_upscale = upscale2.resize((upscale2.width //
|
| 159 |
return sd_image, downscaled_upscale, prompt
|
| 160 |
|
| 161 |
def run_inference_and_upload_30(prompt, neg_prompt_1, neg_prompt_2, neg_prompt_3, width, height, guidance, steps, save_consent, progress=gr.Progress(track_tqdm=True)):
|
|
@@ -218,7 +218,7 @@ with gr.Blocks(theme=gr.themes.Origin(), css=css) as demo:
|
|
| 218 |
)
|
| 219 |
run_button_30 = gr.Button("Run30", scale=0, variant="primary")
|
| 220 |
run_button_60 = gr.Button("Run60", scale=0, variant="primary")
|
| 221 |
-
|
| 222 |
result = gr.Image(label="Result", show_label=False, type="pil")
|
| 223 |
save_consent_checkbox = gr.Checkbox(
|
| 224 |
label="✅ Anonymously upload result to a public gallery",
|
|
@@ -230,8 +230,8 @@ with gr.Blocks(theme=gr.themes.Origin(), css=css) as demo:
|
|
| 230 |
negative_prompt_2 = gr.Text(label="Negative prompt 2", max_lines=1, placeholder="Enter a second negative prompt", value="unrealistic, cartoon, anime, sketch, painting, drawing, illustration, graphic, digital art, render, 3d, blurry, deformed, disfigured, poorly drawn, bad anatomy, mutated, extra limbs, ugly, out of frame, bad composition, low resolution, grainy, pixelated, noisy, oversaturated, undersaturated, (worst quality, low quality:1.3), (bad hands, missing fingers:1.2)")
|
| 231 |
negative_prompt_3 = gr.Text(label="Negative prompt 3", max_lines=1, placeholder="Enter a third negative prompt", value="(worst quality, low quality:1.3), (bad anatomy, bad hands, missing fingers, extra digit, fewer digits:1.2), (blurry:1.1), cropped, watermark, text, signature, logo, jpeg artifacts, (ugly, deformed, disfigured:1.2), (poorly drawn:1.2), mutated, extra limbs, (bad proportions, gross proportions:1.2), (malformed limbs, missing arms, missing legs, extra arms, extra legs:1.2), (fused fingers, too many fingers, long neck:1.2), (unnatural body, unnatural pose:1.1), out of frame, (bad composition, poorly composed:1.1), (oversaturated, undersaturated:1.1), (grainy, pixelated:1.1), (low resolution, noisy:1.1), (unrealistic, distorted:1.1), (extra fingers, mutated hands, poorly drawn hands, bad hands:1.3), (missing fingers:1.3)")
|
| 232 |
with gr.Row():
|
| 233 |
-
width = gr.Slider(label="Width", minimum=256, maximum=MAX_IMAGE_SIZE, step=32, value=
|
| 234 |
-
height = gr.Slider(label="Height", minimum=256, maximum=MAX_IMAGE_SIZE, step=32, value=
|
| 235 |
with gr.Row():
|
| 236 |
guidance_scale = gr.Slider(label="Guidance scale", minimum=0.0, maximum=30.0, step=0.1, value=4.2)
|
| 237 |
num_inference_steps = gr.Slider(label="Inference steps", minimum=1, maximum=150, step=1, value=60)
|
|
@@ -268,8 +268,8 @@ with gr.Blocks(theme=gr.themes.Origin(), css=css) as demo:
|
|
| 268 |
outputs=[result, expanded_prompt_output],
|
| 269 |
)
|
| 270 |
|
| 271 |
-
|
| 272 |
-
fn=
|
| 273 |
inputs=[
|
| 274 |
prompt,
|
| 275 |
negative_prompt_1,
|
|
|
|
| 115 |
upscale = upscaler_2(sd_image, tiling=True, tile_width=256, tile_height=256)
|
| 116 |
upscale2 = upscaler_2(upscale, tiling=True, tile_width=256, tile_height=256)
|
| 117 |
print('-- got upscaled image --')
|
| 118 |
+
downscaled_upscale = upscale2.resize((upscale2.width // 16, upscale2.height // 16), Image.LANCZOS)
|
| 119 |
return sd_image, downscaled_upscale, prompt
|
| 120 |
|
| 121 |
@spaces.GPU(duration=70)
|
|
|
|
| 135 |
upscale = upscaler_2(sd_image, tiling=True, tile_width=256, tile_height=256)
|
| 136 |
upscale2 = upscaler_2(upscale, tiling=True, tile_width=256, tile_height=256)
|
| 137 |
print('-- got upscaled image --')
|
| 138 |
+
downscaled_upscale = upscale2.resize((upscale2.width // 16, upscale2.height // 16), Image.LANCZOS)
|
| 139 |
return sd_image, downscaled_upscale, prompt
|
| 140 |
|
| 141 |
+
@spaces.GPU(duration=120)
|
| 142 |
+
def generate_images_110(prompt, neg_prompt_1, neg_prompt_2, neg_prompt_3, width, height, guidance, steps, progress=gr.Progress(track_tqdm=True)):
|
| 143 |
seed = random.randint(0, MAX_SEED)
|
| 144 |
generator = torch.Generator(device=device).manual_seed(seed)
|
| 145 |
print('-- generating image --')
|
|
|
|
| 155 |
upscale = upscaler_2(sd_image, tiling=True, tile_width=256, tile_height=256)
|
| 156 |
upscale2 = upscaler_2(upscale, tiling=True, tile_width=256, tile_height=256)
|
| 157 |
print('-- got upscaled image --')
|
| 158 |
+
downscaled_upscale = upscale2.resize((upscale2.width // 16, upscale2.height // 16), Image.LANCZOS)
|
| 159 |
return sd_image, downscaled_upscale, prompt
|
| 160 |
|
| 161 |
def run_inference_and_upload_30(prompt, neg_prompt_1, neg_prompt_2, neg_prompt_3, width, height, guidance, steps, save_consent, progress=gr.Progress(track_tqdm=True)):
|
|
|
|
| 218 |
)
|
| 219 |
run_button_30 = gr.Button("Run30", scale=0, variant="primary")
|
| 220 |
run_button_60 = gr.Button("Run60", scale=0, variant="primary")
|
| 221 |
+
run_button_110 = gr.Button("Run100", scale=0, variant="primary")
|
| 222 |
result = gr.Image(label="Result", show_label=False, type="pil")
|
| 223 |
save_consent_checkbox = gr.Checkbox(
|
| 224 |
label="✅ Anonymously upload result to a public gallery",
|
|
|
|
| 230 |
negative_prompt_2 = gr.Text(label="Negative prompt 2", max_lines=1, placeholder="Enter a second negative prompt", value="unrealistic, cartoon, anime, sketch, painting, drawing, illustration, graphic, digital art, render, 3d, blurry, deformed, disfigured, poorly drawn, bad anatomy, mutated, extra limbs, ugly, out of frame, bad composition, low resolution, grainy, pixelated, noisy, oversaturated, undersaturated, (worst quality, low quality:1.3), (bad hands, missing fingers:1.2)")
|
| 231 |
negative_prompt_3 = gr.Text(label="Negative prompt 3", max_lines=1, placeholder="Enter a third negative prompt", value="(worst quality, low quality:1.3), (bad anatomy, bad hands, missing fingers, extra digit, fewer digits:1.2), (blurry:1.1), cropped, watermark, text, signature, logo, jpeg artifacts, (ugly, deformed, disfigured:1.2), (poorly drawn:1.2), mutated, extra limbs, (bad proportions, gross proportions:1.2), (malformed limbs, missing arms, missing legs, extra arms, extra legs:1.2), (fused fingers, too many fingers, long neck:1.2), (unnatural body, unnatural pose:1.1), out of frame, (bad composition, poorly composed:1.1), (oversaturated, undersaturated:1.1), (grainy, pixelated:1.1), (low resolution, noisy:1.1), (unrealistic, distorted:1.1), (extra fingers, mutated hands, poorly drawn hands, bad hands:1.3), (missing fingers:1.3)")
|
| 232 |
with gr.Row():
|
| 233 |
+
width = gr.Slider(label="Width", minimum=256, maximum=MAX_IMAGE_SIZE, step=32, value=1024)
|
| 234 |
+
height = gr.Slider(label="Height", minimum=256, maximum=MAX_IMAGE_SIZE, step=32, value=1024)
|
| 235 |
with gr.Row():
|
| 236 |
guidance_scale = gr.Slider(label="Guidance scale", minimum=0.0, maximum=30.0, step=0.1, value=4.2)
|
| 237 |
num_inference_steps = gr.Slider(label="Inference steps", minimum=1, maximum=150, step=1, value=60)
|
|
|
|
| 268 |
outputs=[result, expanded_prompt_output],
|
| 269 |
)
|
| 270 |
|
| 271 |
+
run_button_110.click(
|
| 272 |
+
fn=run_inference_and_upload_110,
|
| 273 |
inputs=[
|
| 274 |
prompt,
|
| 275 |
negative_prompt_1,
|