MaxMilan1
commited on
Commit
·
987f112
1
Parent(s):
70ea20b
more changements
Browse files- app.py +11 -5
- requirements.txt +5 -1
app.py
CHANGED
@@ -3,6 +3,10 @@ import gradio as gr
|
|
3 |
import torch
|
4 |
from diffusers import DiffusionPipeline, AutoencoderKL
|
5 |
import rembg
|
|
|
|
|
|
|
|
|
6 |
|
7 |
model_id = "dataautogpt3/OpenDalleV1.1"
|
8 |
vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16)
|
@@ -18,9 +22,12 @@ pipe.to("cuda")
|
|
18 |
@spaces.GPU
|
19 |
def generate_image(prompt, neg_prompt):
|
20 |
prompt += "no background, side view, minimalist shot"
|
21 |
-
|
22 |
-
|
23 |
-
|
|
|
|
|
|
|
24 |
|
25 |
_TITLE = "Shoe Generator"
|
26 |
with gr.Blocks(_TITLE) as ShoeGen:
|
@@ -30,10 +37,9 @@ with gr.Blocks(_TITLE) as ShoeGen:
|
|
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"
|
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()
|
|
|
3 |
import torch
|
4 |
from diffusers import DiffusionPipeline, AutoencoderKL
|
5 |
import rembg
|
6 |
+
from io import BytesIO
|
7 |
+
import PIL.Image as Image
|
8 |
+
import cv2
|
9 |
+
import numpy
|
10 |
|
11 |
model_id = "dataautogpt3/OpenDalleV1.1"
|
12 |
vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16)
|
|
|
22 |
@spaces.GPU
|
23 |
def generate_image(prompt, neg_prompt):
|
24 |
prompt += "no background, side view, minimalist shot"
|
25 |
+
image_bytes = pipe(prompt, negative_prompt=neg_prompt)
|
26 |
+
pil_image = Image.open(BytesIO(image_bytes))
|
27 |
+
opencvImage = cv2.cvtColor(numpy.array(pil_image), cv2.COLOR_RGB2BGR)
|
28 |
+
|
29 |
+
cv2_image = rembg.remove(opencvImage)
|
30 |
+
return pil_image, cv2_image
|
31 |
|
32 |
_TITLE = "Shoe Generator"
|
33 |
with gr.Blocks(_TITLE) as ShoeGen:
|
|
|
37 |
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")
|
38 |
button_gen = gr.Button("Generate Image")
|
39 |
with gr.Column():
|
40 |
+
image = gr.Image(label="Generated Image")
|
41 |
image2 = gr.Image(label="Generated Image without background", show_download_button=True)
|
42 |
|
|
|
43 |
button_gen.click(generate_image, inputs=[prompt], outputs=[image, image2])
|
44 |
|
45 |
ShoeGen.launch()
|
requirements.txt
CHANGED
@@ -4,4 +4,8 @@ diffusers==0.26.3
|
|
4 |
transformers==4.38.1
|
5 |
accelerate==0.27.2
|
6 |
xformers
|
7 |
-
rembg
|
|
|
|
|
|
|
|
|
|
4 |
transformers==4.38.1
|
5 |
accelerate==0.27.2
|
6 |
xformers
|
7 |
+
rembg
|
8 |
+
Pillow
|
9 |
+
Python-IO
|
10 |
+
numpy
|
11 |
+
opencv-python
|