MaxMilan1
commited on
Commit
·
92ecdcd
1
Parent(s):
b684483
more changes
Browse files- app.py +13 -7
- requirements.txt +2 -1
app.py
CHANGED
@@ -4,8 +4,13 @@ import torch
|
|
4 |
from diffusers import DiffusionPipeline
|
5 |
import rembg
|
6 |
|
7 |
-
model_id = "stabilityai/stable-diffusion-
|
8 |
-
pipe = DiffusionPipeline.from_pretrained(model_id
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
pipe.to("cuda")
|
11 |
|
@@ -14,20 +19,21 @@ pipe.to("cuda")
|
|
14 |
def generate_image(prompt):
|
15 |
|
16 |
image = pipe(prompt).images
|
17 |
-
|
18 |
-
return image
|
19 |
|
20 |
_TITLE = "Shoe Generator"
|
21 |
with gr.Blocks(_TITLE) as ShoeGen:
|
22 |
with gr.Row():
|
23 |
with gr.Column():
|
24 |
prompt = gr.Textbox(label="Enter a prompt")
|
|
|
25 |
button_gen = gr.Button("Generate Image")
|
26 |
with gr.Column():
|
27 |
-
|
28 |
-
|
29 |
|
30 |
|
31 |
-
button_gen.click(generate_image, inputs=[prompt], outputs=image)
|
32 |
|
33 |
ShoeGen.launch()
|
|
|
4 |
from diffusers import DiffusionPipeline
|
5 |
import rembg
|
6 |
|
7 |
+
model_id = "stabilityai/stable-diffusion-xl-base-1.0"
|
8 |
+
pipe = DiffusionPipeline.from_pretrained(model_id,
|
9 |
+
torch_dtype=torch.float16,
|
10 |
+
use_safetensors=True,)
|
11 |
+
|
12 |
+
pipe.load_lora_weights("CiroN2022/shoes", weight_name="shoes.safetensors", adapter_name="shoes")
|
13 |
+
pipe.set_adapters("shoes")
|
14 |
|
15 |
pipe.to("cuda")
|
16 |
|
|
|
19 |
def generate_image(prompt):
|
20 |
|
21 |
image = pipe(prompt).images
|
22 |
+
image2 = rembg.remove(image)
|
23 |
+
return image, image2
|
24 |
|
25 |
_TITLE = "Shoe Generator"
|
26 |
with gr.Blocks(_TITLE) as ShoeGen:
|
27 |
with gr.Row():
|
28 |
with gr.Column():
|
29 |
prompt = gr.Textbox(label="Enter a prompt")
|
30 |
+
neg_prompt = gr.Textbox(label="Enter a negative prompt", value="low quality, watermark, ugly, tiling, poorly drawn hands, poorly drawn feet, poorly drawn face, out of frame, extra limbs, body out of frame, blurry, bad anatomy, blurred, watermark, grainy, signature, cut off, draft, closed eyes, text, logo")
|
31 |
button_gen = gr.Button("Generate Image")
|
32 |
with gr.Column():
|
33 |
+
image = gr.Image(label="Generated Image", show_download_button=True)
|
34 |
+
image2 = gr.Image(label="Generated Image without background", show_download_button=True)
|
35 |
|
36 |
|
37 |
+
button_gen.click(generate_image, inputs=[prompt], outputs=[image, image2])
|
38 |
|
39 |
ShoeGen.launch()
|
requirements.txt
CHANGED
@@ -3,4 +3,5 @@ gradio
|
|
3 |
diffusers==0.26.3
|
4 |
transformers==4.38.1
|
5 |
accelerate==0.27.2
|
6 |
-
xformers
|
|
|
|
3 |
diffusers==0.26.3
|
4 |
transformers==4.38.1
|
5 |
accelerate==0.27.2
|
6 |
+
xformers
|
7 |
+
rembg
|