MaxMilan1
commited on
Commit
·
63f29cf
1
Parent(s):
6148334
massive changes / restucturing
Browse files- app.py +16 -26
- util/text_img.py +17 -0
app.py
CHANGED
@@ -1,33 +1,23 @@
|
|
1 |
-
import spaces
|
2 |
import gradio as gr
|
3 |
-
import
|
4 |
-
from diffusers import DiffusionPipeline
|
5 |
-
import rembg
|
6 |
-
|
7 |
-
pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16, use_safetensors=True, variant="fp16")
|
8 |
-
pipe.to("cuda")
|
9 |
-
|
10 |
-
# Function to generate an image from text using diffusion
|
11 |
-
@spaces.GPU
|
12 |
-
def generate_image(prompt):
|
13 |
-
prompt += "no background, side view, minimalist shot"
|
14 |
-
|
15 |
-
image = pipe(prompt).images[0]
|
16 |
-
image2 = rembg.remove(image)
|
17 |
-
|
18 |
-
return image, image2
|
19 |
|
20 |
_TITLE = "Shoe Generator"
|
21 |
with gr.Blocks(_TITLE) as ShoeGen:
|
22 |
-
with gr.
|
23 |
-
with gr.
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
|
|
|
|
|
|
30 |
|
31 |
-
|
32 |
|
|
|
|
|
|
|
33 |
ShoeGen.launch()
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from util.text_img import generate_image
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
_TITLE = "Shoe Generator"
|
5 |
with gr.Blocks(_TITLE) as ShoeGen:
|
6 |
+
with gr.Tab("Text to Image Generator"):
|
7 |
+
with gr.Row():
|
8 |
+
with gr.Column():
|
9 |
+
prompt = gr.Textbox(label="Enter a discription of a shoe")
|
10 |
+
# 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")
|
11 |
+
button_gen = gr.Button("Generate Image")
|
12 |
+
with gr.Column():
|
13 |
+
with gr.Tab("With Background"):
|
14 |
+
image = gr.Image(label="Generated Image", show_download_button=True, show_label=False)
|
15 |
+
with gr.Tab("Without Background"):
|
16 |
+
image_nobg = gr.Image(label="Generated Image", show_download_button=True, show_label=False)
|
17 |
|
18 |
+
button_gen.click(generate_image, inputs=[prompt], outputs=[image, image_nobg])
|
19 |
|
20 |
+
with gr.Tab("Image to Video Generator (V3D)"):
|
21 |
+
pass
|
22 |
+
|
23 |
ShoeGen.launch()
|
util/text_img.py
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import spaces
|
2 |
+
import rembg
|
3 |
+
import torch
|
4 |
+
from diffusers import DiffusionPipeline
|
5 |
+
|
6 |
+
pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16, use_safetensors=True, variant="fp16")
|
7 |
+
pipe.to("cuda")
|
8 |
+
|
9 |
+
# Function to generate an image from text using diffusion
|
10 |
+
@spaces.GPU
|
11 |
+
def generate_image(prompt):
|
12 |
+
prompt += "no background, side view, minimalist shot"
|
13 |
+
|
14 |
+
image = pipe(prompt).images[0]
|
15 |
+
image2 = rembg.remove(image)
|
16 |
+
|
17 |
+
return image, image2
|