File size: 686 Bytes
dc4645f
4638d35
2f056e9
dc4645f
d149aba
dc4645f
2f056e9
5b7507c
4638d35
 
dc4645f
 
2f056e9
 
dc4645f
d149aba
2f056e9
 
 
 
 
 
 
dc4645f
2f056e9
d149aba
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
import gradio as gr
from diffusers import StableDiffusionPipeline
import torch

# Initialisation du pipeline Stable Diffusion en CPU
pipe = StableDiffusionPipeline.from_pretrained(
    "runwayml/stable-diffusion-v1-5",
    torch_dtype=torch.float32
)
pipe = pipe.to("cpu")

def generate_image(prompt):
    image = pipe(prompt).images[0]
    return image

# Création de l'interface Gradio
demo = gr.Interface(
    fn=generate_image,
    inputs=gr.Textbox(label="Prompt"),
    outputs=gr.Image(label="Generated Image"),
    title="BID Creativity Generator",
    description="Générateur d'images Stable Diffusion CPU"
)

if __name__ == "__main__":
    demo.launch(server_name="0.0.0.0")