File size: 894 Bytes
12863e1
2cf6be0
 
 
05d3d42
2cf6be0
2457f9c
6b0d828
 
2cf6be0
 
 
12863e1
262e1d3
2cf6be0
05d3d42
 
 
2cf6be0
fa0ee64
 
 
 
262e1d3
f0f8ecd
262e1d3
7d79b00
22eb08b
ad9ba71
2cf6be0
05d3d42
2cf6be0
fa0ee64
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import spaces
import gradio as gr
import torch
from diffusers import DiffusionPipeline
import rembg

model_id = "stabilityai/stable-diffusion-2-1"
pipe = DiffusionPipeline.from_pretrained(model_id)

pipe.to("cuda")

# Function to generate an image from text using diffusion
@spaces.GPU
def generate_image(prompt):
    
    image = pipe(prompt).images
    image = rembg.remove(image)
    return image

_TITLE = "Shoe Generator"
with gr.Blocks(_TITLE) as ShoeGen:
    with gr.Row():
        with gr.Column():
            prompt = gr.Textbox(label="Enter a prompt")
            button_gen = gr.Button("Generate Image")
        with gr.Column():
        #  show images
            gallery = gr.Gallery(label="Generated images", show_label=False, elem_id="gallery", show_download_button=True, columns=[2])
    

    button_gen.click(generate_image, inputs=[prompt], outputs=image)

ShoeGen.launch()