sandeepmajumdar commited on
Commit
abdc685
1 Parent(s): ea10931

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -14
app.py CHANGED
@@ -9,13 +9,13 @@ has_cuda = torch.cuda.is_available()
9
  device = torch.device('cpu' if not has_cuda else 'cuda')
10
  pipe = pipe.to(device)
11
 
12
- def inference(diffusion_prompt):
13
  samples = 4
14
  generator = torch.Generator(device=device)
15
  torch.cuda.empty_cache()
16
  with autocast("cuda"):
17
  images_list = pipe(
18
- [diffusion_prompt] * samples,
19
  height=256, width=384,
20
  num_inference_steps=50,
21
  )
@@ -25,15 +25,7 @@ def inference(diffusion_prompt):
25
  return images
26
 
27
 
28
- with gr.Blocks() as demo:
29
- gr.Markdown("# Text to Image Generator")
30
- with gr.Row():
31
- prompt = gr.Textbox(
32
- lines=1,
33
- placeholder="Enter your prompt..",
34
- interactive=True,
35
- label="Prompt"
36
- )
37
- submit = gr.Button("Run")
38
- submit.click(fn=inference, inputs=[prompt], outputs=[images])
39
- demo.launch()
 
9
  device = torch.device('cpu' if not has_cuda else 'cuda')
10
  pipe = pipe.to(device)
11
 
12
+ def convert(prompt):
13
  samples = 4
14
  generator = torch.Generator(device=device)
15
  torch.cuda.empty_cache()
16
  with autocast("cuda"):
17
  images_list = pipe(
18
+ [prompt] * samples,
19
  height=256, width=384,
20
  num_inference_steps=50,
21
  )
 
25
  return images
26
 
27
 
28
+ gr.Interface(convert,
29
+ inputs = [gr.inputs.Textbox(label="Enter text")],
30
+ outputs = [gr.outputs.Image(label="Generated Image")],
31
+ title="Text to Image Generation").launch()