Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,6 +6,7 @@ import random
|
|
| 6 |
from diffusers import DiffusionPipeline, StableDiffusionPipeline
|
| 7 |
from peft import PeftModel, LoraConfig
|
| 8 |
import torch
|
|
|
|
| 9 |
|
| 10 |
model_repo_id = "stabilityai/sdxl-turbo" # Replace to the model you would like to use
|
| 11 |
|
|
@@ -60,6 +61,9 @@ def infer(
|
|
| 60 |
generator=generator,
|
| 61 |
).images[0]
|
| 62 |
|
|
|
|
|
|
|
|
|
|
| 63 |
return image, seed
|
| 64 |
|
| 65 |
css = """
|
|
@@ -113,7 +117,11 @@ with gr.Blocks(css=css) as demo:
|
|
| 113 |
)
|
| 114 |
|
| 115 |
randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
|
| 116 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
with gr.Row():
|
| 118 |
width = gr.Slider(
|
| 119 |
label="Width",
|
|
@@ -170,6 +178,7 @@ with gr.Blocks(css=css) as demo:
|
|
| 170 |
guidance_scale,
|
| 171 |
lora_scale,
|
| 172 |
num_inference_steps,
|
|
|
|
| 173 |
],
|
| 174 |
outputs=[result, seed],
|
| 175 |
)
|
|
|
|
| 6 |
from diffusers import DiffusionPipeline, StableDiffusionPipeline
|
| 7 |
from peft import PeftModel, LoraConfig
|
| 8 |
import torch
|
| 9 |
+
from rembg import remove
|
| 10 |
|
| 11 |
model_repo_id = "stabilityai/sdxl-turbo" # Replace to the model you would like to use
|
| 12 |
|
|
|
|
| 61 |
generator=generator,
|
| 62 |
).images[0]
|
| 63 |
|
| 64 |
+
if remove_background:
|
| 65 |
+
image = remove(image)
|
| 66 |
+
|
| 67 |
return image, seed
|
| 68 |
|
| 69 |
css = """
|
|
|
|
| 117 |
)
|
| 118 |
|
| 119 |
randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
|
| 120 |
+
with gr.Row():
|
| 121 |
+
remove_background = gr.Checkbox(
|
| 122 |
+
label="Delete background?", value=True
|
| 123 |
+
)
|
| 124 |
+
|
| 125 |
with gr.Row():
|
| 126 |
width = gr.Slider(
|
| 127 |
label="Width",
|
|
|
|
| 178 |
guidance_scale,
|
| 179 |
lora_scale,
|
| 180 |
num_inference_steps,
|
| 181 |
+
remove_backgroung
|
| 182 |
],
|
| 183 |
outputs=[result, seed],
|
| 184 |
)
|