vsrinivas commited on
Commit
7c978df
·
1 Parent(s): c23aa75

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -9
app.py CHANGED
@@ -3,10 +3,8 @@ from transformers import pipeline
3
  import torch
4
  from diffusers import DiffusionPipeline
5
 
6
- # def get_completion(prompt,params):
7
- # return pipeline(prompt=prompt, height=params['height'], width=params['width'], num_inference_steps=params['num_inference_steps'], guidance_scale=params['guidance_scale'])['sample'][0]
8
- def get_completion(prompt):
9
- return pipeline(prompt=prompt)['sample'][0]
10
 
11
  def generate(prompt,steps,guidance,width,height):
12
  params = {
@@ -15,14 +13,14 @@ def generate(prompt,steps,guidance,width,height):
15
  "width": width,
16
  "height": height
17
  }
18
- # output = get_completion(prompt,params)
19
- output = get_completion(prompt)
20
  return output
21
 
22
  pipeline = DiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5", torch_dtype=torch.float16)
23
 
24
  with gr.Blocks() as demo:
25
- gr.Markdown("# Image Generation with Stable Diffusion")
 
26
  with gr.Row():
27
  with gr.Column(scale=4):
28
  prompt = gr.Textbox(label="Your Prompt") #Give prompt some real estate
@@ -32,8 +30,8 @@ with gr.Blocks() as demo:
32
  # negative_prompt = gr.Textbox(label="Negative prompt")
33
  with gr.Row():
34
  with gr.Column():
35
- steps = gr.Slider(label="Inference Steps", minimum=1, maximum=100, value=25,
36
- info="In many steps will the denoiser denoise the image?")
37
  guidance = gr.Slider(label="Guidance Scale", minimum=1.0, maximum=20.0, value=7.0,
38
  info="Controls how much the text prompt influences the result")
39
  with gr.Column():
 
3
  import torch
4
  from diffusers import DiffusionPipeline
5
 
6
+ def get_completion(prompt,params):
7
+ return pipeline(prompt=prompt, height=params['height'], width=params['width'], num_inference_steps=params['num_inference_steps'], guidance_scale=params['guidance_scale'])['sample'][0]
 
 
8
 
9
  def generate(prompt,steps,guidance,width,height):
10
  params = {
 
13
  "width": width,
14
  "height": height
15
  }
16
+ output = get_completion(prompt,params)
 
17
  return output
18
 
19
  pipeline = DiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5", torch_dtype=torch.float16)
20
 
21
  with gr.Blocks() as demo:
22
+ gr.Markdown("# Image Generation Demo & Test App by Srinivas")
23
+ gr.Markdown("## Generates an Image based on Your Promt inptted and Optional parameters selected")
24
  with gr.Row():
25
  with gr.Column(scale=4):
26
  prompt = gr.Textbox(label="Your Prompt") #Give prompt some real estate
 
30
  # negative_prompt = gr.Textbox(label="Negative prompt")
31
  with gr.Row():
32
  with gr.Column():
33
+ steps = int(gr.Slider(label="Inference Steps", minimum=1, maximum=100, value=25,
34
+ info="In many steps will the denoiser denoise the image?"))
35
  guidance = gr.Slider(label="Guidance Scale", minimum=1.0, maximum=20.0, value=7.0,
36
  info="Controls how much the text prompt influences the result")
37
  with gr.Column():