philipp-zettl commited on
Commit
aa90372
·
verified ·
1 Parent(s): 8f03093

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -1
app.py CHANGED
@@ -1,11 +1,32 @@
1
  import gradio as gr
2
  import os
 
 
 
3
 
4
- app = gr.load(
 
5
  "models/philipp-zettl/jon_juarez-lora",
 
6
  hf_token=os.environ.get('HF_TOKEN')
7
  )
 
 
 
 
 
8
 
 
 
 
 
 
 
 
 
 
 
 
9
  with app as demo:
10
 
11
  demo.examples = [
 
1
  import gradio as gr
2
  import os
3
+ import spaces
4
+ import torch
5
+ from diffusers import DiffusionPipeline
6
 
7
+
8
+ pipe = DiffusionPipeline.from_pretrained(
9
  "models/philipp-zettl/jon_juarez-lora",
10
+ torch_dtype=torch.float32,
11
  hf_token=os.environ.get('HF_TOKEN')
12
  )
13
+ pipe.to('cuda')
14
+ @spaces.GPU
15
+ def generate(prompt, negative_prompt, num_inference_steps, width, height):
16
+ return pipe(prompt, negative_prompt=negative_prompt, num_inference_steps=num_inference_steps, width=width, height=height).images
17
+
18
 
19
+ app = gr.Interface(
20
+ fn=generate,
21
+ inputs=[
22
+ gr.Text(label="Prompt"),
23
+ gr.Text("", label="Negative Prompt"),
24
+ gr.Number(45, label="Number inference steps"),
25
+ gr.Number(1024, label='image width'),
26
+ gr.Number(1024, label='image height'),
27
+ ],
28
+ outputs=gr.Gallery(),
29
+ )
30
  with app as demo:
31
 
32
  demo.examples = [