File size: 486 Bytes
ef56345
 
 
a2d1cee
ef56345
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import gradio as gr
import torch
import diffusers
pipe=diffusers.StableDiffusionPipeline.from_pretrained('stabilityai/stable-diffusion-2-1',torch_dtype=torch.float32)
pipe.to('cuda')
def gen(prompt):
  img=pipe(prompt)[0][0]
  return img
  

with gr.Blocks() as demo:
    prompt = gr.Textbox(label="Prompt")
    output = gr.Image(label="Output Box")
    greet_btn = gr.Button("Generate")
    greet_btn.click(fn=gen, inputs=prompt, outputs=output, api_name="gen")
demo.launch(debug=True)