File size: 557 Bytes
fe3676f
280766f
1cb0342
 
 
 
 
 
 
 
 
fe3676f
1cb0342
 
 
 
 
 
 
fe3676f
1cb0342
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from diffusers import DiffusionPipeline

def generate_image(prompt):
    model_id = "runwayml/stable-diffusion-v1-5"
    pipeline = DiffusionPipeline.from_pretrained(model_id)
    pipeline = pipeline.to("cuda")
    
    generator = torch.Generator("cuda").manual_seed(0)
    image = pipeline(prompt, generator=generator).images[0]
    
    return image

iface = gr.Interface(
    fn=generate_image,
    inputs="text",
    outputs="image",
    title="Diffusion d'images",
    description="Générez des images à partir d'une description.",
)

iface.launch()