anzorq commited on
Commit
26063e6
1 Parent(s): a0b75d7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -6
app.py CHANGED
@@ -1,24 +1,28 @@
1
  from diffusers import StableDiffusionPipeline
2
  import gradio as gr
 
 
3
 
4
- pipe = StableDiffusionPipeline.from_pretrained("nitrosocke/Arcane-Diffusion")
5
- pipe = pipe.to("cuda")
 
6
 
7
- def inference(prompt, guidance, steps):
8
- all_images = []
9
  images = pipe([prompt] * 1, num_inference_steps=int(steps), guidance_scale=guidance, width=512, height=512).images
10
  all_images.extend(images)
11
  return all_images
12
 
13
  with gr.Blocks() as demo:
14
  with gr.Row():
 
15
  with gr.Column():
16
  prompt = gr.Textbox(label="prompt")
17
  guidance = gr.Slider(label="guidance scale", value=7.5, maximum=15)
18
  steps = gr.Slider(label="steps", value=50, maximum=100, minimum=2)
19
  run = gr.Button(value="Run")
20
  with gr.Column():
21
- gallery = gr.Gallery(show_label=False)
22
 
23
  run.click(inference, inputs=[prompt, guidance, steps], outputs=gallery)
24
  gr.Examples([
@@ -27,7 +31,7 @@ with gr.Blocks() as demo:
27
  ["portrait of a beautiful alyx vance half life, volume lighting, concept art, by greg rutkowski!!, colorful, xray melting colors!!, arcane style", 7, 50],
28
  ["Aloy from Horizon: Zero Dawn, half body portrait, videogame cover art, highly detailed, digital painting, artstation, concept art, smooth, detailed armor, sharp focus, beautiful face, illustration, art by Artgerm and greg rutkowski and alphonse mucha, arcane style", 7, 50],
29
  ["fantasy portrait painting, digital art, arcane style", 4, 30],
30
- ], [prompt, guidance, steps], gallery, inference, cache_examples=False)
31
 
32
  demo.queue()
33
  demo.launch()
 
1
  from diffusers import StableDiffusionPipeline
2
  import gradio as gr
3
+ import torch
4
+ from utils import device
5
 
6
+ pipe = StableDiffusionPipeline.from_pretrained("nitrosocke/Arcane-Diffusion", torch_dtype=torch.float16)
7
+ if torch.cuda.is_available():
8
+ pipe = pipe.to("cuda")
9
 
10
+ def inference(prompt, guidance, steps):
11
+ all_images = []
12
  images = pipe([prompt] * 1, num_inference_steps=int(steps), guidance_scale=guidance, width=512, height=512).images
13
  all_images.extend(images)
14
  return all_images
15
 
16
  with gr.Blocks() as demo:
17
  with gr.Row():
18
+ gr.Markdown(f"Running on: {device}")
19
  with gr.Column():
20
  prompt = gr.Textbox(label="prompt")
21
  guidance = gr.Slider(label="guidance scale", value=7.5, maximum=15)
22
  steps = gr.Slider(label="steps", value=50, maximum=100, minimum=2)
23
  run = gr.Button(value="Run")
24
  with gr.Column():
25
+ gallery = gr.Gallery()
26
 
27
  run.click(inference, inputs=[prompt, guidance, steps], outputs=gallery)
28
  gr.Examples([
 
31
  ["portrait of a beautiful alyx vance half life, volume lighting, concept art, by greg rutkowski!!, colorful, xray melting colors!!, arcane style", 7, 50],
32
  ["Aloy from Horizon: Zero Dawn, half body portrait, videogame cover art, highly detailed, digital painting, artstation, concept art, smooth, detailed armor, sharp focus, beautiful face, illustration, art by Artgerm and greg rutkowski and alphonse mucha, arcane style", 7, 50],
33
  ["fantasy portrait painting, digital art, arcane style", 4, 30],
34
+ ], [prompt, guidance, steps], gallery, inference, cache_examples=torch.cuda.is_available())
35
 
36
  demo.queue()
37
  demo.launch()