bariscal commited on
Commit
8b657bf
·
1 Parent(s): 2043f73

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -1
app.py CHANGED
@@ -1,3 +1,33 @@
1
  import gradio as gr
2
 
3
- gr.Interface.load("models/bariscal/cbst_style").launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
 
3
+ gr.Interface.load("models/bariscal/cbst_style").launch()
4
+
5
+ def inference(prompt, negative_prompt, num_samples, height=512, width=512, num_inference_steps=50, guidance_scale=7.5):
6
+ with torch.autocast("cuda"), torch.inference_mode():
7
+ return pipe(
8
+ prompt, height=int(height), width=int(width),
9
+ negative_prompt=negative_prompt,
10
+ num_images_per_prompt=int(num_samples),
11
+ num_inference_steps=int(num_inference_steps), guidance_scale=guidance_scale,
12
+ generator=g_cuda
13
+ ).images
14
+
15
+ with gr.Blocks() as demo:
16
+ with gr.Row():
17
+ with gr.Column():
18
+ prompt = gr.Textbox(label="Prompt", value="photo of zwx dog in a bucket")
19
+ negative_prompt = gr.Textbox(label="Negative Prompt", value="")
20
+ run = gr.Button(value="Generate")
21
+ with gr.Row():
22
+ num_samples = gr.Number(label="Number of Samples", value=4)
23
+ guidance_scale = gr.Number(label="Guidance Scale", value=7.5)
24
+ with gr.Row():
25
+ height = gr.Number(label="Height", value=512)
26
+ width = gr.Number(label="Width", value=512)
27
+ num_inference_steps = gr.Slider(label="Steps", value=24)
28
+ with gr.Column():
29
+ gallery = gr.Gallery()
30
+
31
+ run.click(inference, inputs=[prompt, negative_prompt, num_samples, height, width, num_inference_steps, guidance_scale], outputs=gallery)
32
+
33
+ demo.launch(debug=True)