File size: 1,717 Bytes
2043f73
459a3d3
05a1df1
2043f73
ea9621a
f4e4388
ae2a1df
8b657bf
d83c678
59fdc2b
d83c678
afc61a7
ae2a1df
 
8b657bf
9c6e0bb
 
 
 
 
 
 
f4e4388
8b657bf
 
 
d9084aa
8b657bf
 
 
473fb07
73ad76f
 
df35981
 
73ad76f
 
8b657bf
ae172c3
8b657bf
473fb07
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import gradio as gr
import torch
from diffusers import StableDiffusionPipeline


#gr.Interface.load("models/bariscal/cbst_style")
#pipe = StableDiffusionPipeline.from_pretrained("bariscal/cbst_style", safety_checker=None) #, torch_dtype=torch.float16

# Create a PyTorch generator object
#generator = torch.Generator(device='cpu')


pipe = StableDiffusionPipeline.from_pretrained("bariscal/cbst_style", safety_checker=None)

def inference(prompt, negative_prompt, num_samples, height=512, width=512, num_inference_steps=50, guidance_scale=7.5):
    #with torch.inference_mode():
    return pipe(
        prompt, height=int(height), width=int(width),
        negative_prompt=negative_prompt,
        num_images_per_prompt=int(num_samples),
        num_inference_steps=int(num_inference_steps), guidance_scale=guidance_scale,
    ).images

with gr.Blocks() as demo:
    with gr.Row():
        with gr.Column():
            prompt = gr.Textbox(label="Prompt", value="portrait of human in cbst style")
            negative_prompt = gr.Textbox(label="Negative Prompt", value="")
            run = gr.Button(value="Generate")
        with gr.Column():
            num_samples = gr.Number(label="Number of Samples", value=2)
            guidance_scale = gr.Number(label="Guidance Scale", value=7.5)
    with gr.Row():
        height = gr.Number(label="Height", value=512, interactive = False)
        width = gr.Number(label="Width", value=512, interactive = False)
        num_inference_steps = gr.Slider(label="Steps", value=24)
    gallery = gr.Gallery()

    run.click(inference, inputs=[prompt, negative_prompt, num_samples, height, width, num_inference_steps, guidance_scale], outputs=gallery)

demo.launch(debug=True)