UdacityNoob commited on
Commit
9273f9c
β€’
1 Parent(s): a075000

Add 'precision' parameter for rounding to integer

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -17,8 +17,8 @@ pipe = pipe.to(device)
17
 
18
  # define gradio function
19
  def generate(prompt:str, seed:int, guidance:float, steps:int):
20
- generator = torch.Generator(device).manual_seed(int(seed))
21
- image = pipe(prompt=prompt, generator=generator, guidance_scale=guidance, num_inference_steps=int(steps)).images[0]
22
  return image
23
 
24
  if device == "cuda":
@@ -28,9 +28,10 @@ else:
28
  print("Using CPU.")
29
 
30
  # create the gradio UI
 
31
  demo = gr.Interface(
32
  fn=generate,
33
- inputs=[gr.Textbox(placeholder="castle on a mountain"), gr.Number(value=123456), gr.Slider(0,10), gr.Number(value=50)],
34
  outputs="image",
35
  allow_flagging="never",
36
  )
 
17
 
18
  # define gradio function
19
  def generate(prompt:str, seed:int, guidance:float, steps:int):
20
+ generator = torch.Generator(device).manual_seed(seed)
21
+ image = pipe(prompt=prompt, generator=generator, guidance_scale=guidance, num_inference_steps=steps).images[0]
22
  return image
23
 
24
  if device == "cuda":
 
28
  print("Using CPU.")
29
 
30
  # create the gradio UI
31
+ # set precision to 0 to round value to nearest int
32
  demo = gr.Interface(
33
  fn=generate,
34
+ inputs=[gr.Textbox(placeholder="castle on a mountain"), gr.Number(value=123456, precision=0), gr.Slider(0,10), gr.Number(value=50, precision=0)],
35
  outputs="image",
36
  allow_flagging="never",
37
  )